|
|
|
forefront
Newbie
Registration Date: 06-23-2003
Posts: 5
Location: Long Beach, CA Linux Distro: LindowsOS
Rate Member
Level: 7 [?] |
Experience Points: 390 |
Next Level: 443 |
|
OFFLINE
|
|
When the script is run by NOT run by crontab, it will contain normally contain an argument of stop, start, or restart. When crontab runs it, those arguments will be missing, so the script logic will be to check to see if proxy.php is currently running and if it is, do nothing and quit ... otherwise do the 'start' function.
For example, here's the 'start' function:
start()
{
command="nohup proxy.php &"
exit 0
}
... and the 'stop' function:
stop()
{
command="ps -auxww | grep \"php\" | awk '{print $2}' | xargs kill -9"
exit 0
}
So, if I want to have a check function, I get this far:
check()
{
command="ps -auxww | grep \"php\"" | awk '{print $2}'
}
This returns the PID. If it is not running, it returns nothing. How do I detect nothing? Once I know how to do that, then I can start/exit or just exit. It gets easy then.
This post has been edited 3 time(s), it was last edited by forefront on 06-24-2003 at 23:49.
|
|
06-24-2003 23:42 |
|
|
|
|
|
|
|
|