Using ps to Monitor Processes
In a previous tech tip, we saw how to use kill to monitor processes. Another option is to use ps. With both methods, you can check $? for success/failure. However, note that kill -0 may return failure even if the process actually exists. This happens when the current user has no permission to the process in question, for example: kill -0 1.
To check for a process silently (with no output), use:
kill -0 PID 2>/dev/null ps -p PID >/dev/null










This week 5 lucky Members will receive a copy of The Official Ubuntu Server Book by Benjamin Mako Hill and Linux Journal's very own Kyle Rankin. No entry necessary. Check back here early next week to find out who the lucky Online Members are.




Comments
I tend to use the command
I tend to use the command "pgrep process-pattern". It seems to do the trick as well and has many options to tailor command behaviour.
I like this how2
I like this how2
Post new comment