Hi
I've writen a server is PHP that i want to run every min.
so i can do something like in cron

*/1 * * * * lynx -dump http://www.somedomain.com/myserver.php

But i want to make sure there only 1 running.
The web tells met to check for an prosesid but i running PHP as an apache module so ther is no prosesid.
Does any one have any idears?

Thanks

p.s runing redhat el5

Write a bash script to run that line of code. Something similar to this:

#!/bin/bash

PID_GREP=`ps aux | grep http://www.somedomain.com/myserver.php | grep -v grep`
PID_COUNT=`echo "$PID_GREP" | awk '/myserver.php/ { n++ }; END { print n+0 }'`
if [ ! $PID_COUNT ]
then
lynx -dump http://www.somedomain.com/myserver.php
fi

Rick Bross

Thanks f
But it doesn't work
if i do ps aux i get alot of apache 4365 0.0 0.7 386096 45168 ? S JAN25 1:26 /usr/sbin/httpd but no referens to what website they serves

My fault, as I only search for part of your string. You can search for the entire command string.

If you respond, please cut and paste your script. Every tick mark, punctuation, and space is important in a shell script.

Also, another mistake is the line should be:

if [ $PID_COUNT == 0 ]

I didn't actually run the script. It was intended as a baseline for you.

Thank that helpt a lot

ure code was fare les buggy then my first test about it
sorry for that

think it works now

FYI

- wasn't that sure about lynx -dump option so now using curl
- didn't get awk to read $PID_GREP so had to put it all in one line
- awk don't like . (dot)

#!/bin/bash
PID_COUNT=`ps aux |grep curl |grep -v grep |awk '/layer/tweetserver { n++ }; END {print n+0}'`
if [ $PID_COUNT == 0 ]
then
curl http://www.openeindhoven.nl/layer/tweetsever.php
fi]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.