Check a PHP CLI process is running

mozart_ar

Registered
Jan 17, 2008
3
0
51
Rosario, Santa Fe, Argentina
Check if a PHP CLI process is running

Hello,
I have a custom PHP script that open a UDP for listening incomming connection. I need this process be always active.
Is there a way to do this with chkservd or tailwatch?

The process is initiated from /etc/rc.local , this way:

sudo -u {user} /usr/local/bin/php -f /home/path/to/script.php > /dev/null &

Regards,
-Walter
 
Last edited:

InterServed

Well-Known Member
Jul 10, 2007
268
14
68
cPanel Access Level
DataCenter Provider
You may do a bash script and setup a cron for the script:

Code:
#!/bin/bash
###########################################
script_path=/home/path/to/script.php
process_check=`lsof|grep $script_path|wc -l`
###########################################

if [ $process_check -ge "1" ] then
exit 0;
else
#your start command for your script
sudo -u {user} /usr/local/bin/php -f $script_path > /dev/null &
fi