Quote:
Personally, when I'm checking if a process exists, I run "output=$(ps -p PID)", check the exit code, and if it's 0 (process is running), I go on to parse $output for the actual process name to ensure it's the right process using that PID. Otherwise you can get a false positive when a process writes out its PID, stops running, and hours later some other process happens to be assigned the same PID. Just checking the exit code of "kill -0 PID" or "ps -p PID" in this case will tell you your process is running when it's really not, it could have exited long ago and now something else has simply been assigned that same PID. |
I always check the for the process name anyway, to avoid issues with erroneous pid files
Code:
ps -ef|grep procname |
All times are GMT -5. The time now is 02:08 PM. |