Quantcast
Username/Email:  Password: 

Using ps to Monitor Processes

 in

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
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I tend to use the command

Anonymous's picture

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

Anonymous's picture

I like this how2

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.
  • Use to create page breaks.

More information about formatting options