I'm trying to figure out whether a PHP process is running or not using the ps aux command and passing grep to it, for instance:
I need it to return and tell me whether a process ID on php is running or not but whenever I try the following I always seem to get a result where the result is appending 1234 at the end, what am I missing?
ps aux | grep 'php|1234'
CodePudding user response:
Suggesting pgrep command instead of ps aux
pgrep -af "php"
The reason your get always one line:
phpprocess is not matched withgrep 'php|123123123'ps auxlist thegrepcommand you submitted and thegrepcommand match itselfmaybe you meant
grep -E 'php|123123123'to matchphpor123123123
CodePudding user response:
The solution I've come across thanks to a user above is to do:
ps aux | grep '123456' | grep 'grep' -v
Where 123456 would be the process ID

