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
- Understanding OpenStack's Success
- Ensono M.O.
- Own Your DNS Data
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- From vs. to + for Microsoft and Linux
- Returning Values from Bash Functions
- Natalie Rusk's Scratch Coding Cards (No Starch Press)
- Bash Shell Script: Building a Better March Madness Bracket