I am running websocket server with the nohup command like below.
nohup php -q chat-server.php > ratchet_ws.log &
But it stop working after few hours.So i have created a bash script like below
#!/bin/bash
while true
do
if pgrep php > /dev/null
then
echo "Running"
else
cd /..path../
nohup php -q chat-server.php > ratchet_ws.log &
fi
sleep 1;
done
Then i run the script with below command like below.
nohup sh chk_process.sh > chk_process.log &
The work of the above script if to check my chat-server.php is running or not if it is not running then it will start it again.
if pgrep php > /dev/null
But this line is checking any php process is running or not .But i want it to check only my chat-server.php.