Skip to content
Advertisement

Bash script to check a specific php process is running?

I am running websocket server with the nohup command like below.

JavaScript

But it stop working after few hours.So i have created a bash script like below

JavaScript

Then i run the script with below command like below.

JavaScript

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.

JavaScript

But this line is checking any php process is running or not .But i want it to check only my chat-server.php.

Advertisement

Answer

you can use pgrep -f or pgrep -x option.

entry from man page

-f The pattern is normally only matched against the process name. When -f is set, the full command line is used.
-x Only match processes whose name (or command line if -f is specified) exactly match the pattern.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement