Home » Questions » Computers [ Ask a new question ]

What Linux command can I use to verify that something is in the process list?

What Linux command can I use to verify that something is in the process list?

I want to parse the output of the ps command and return true or false if a program is found. How would anyone here do this? I have access to the command line so it's open for me, no restrictions.

Asked by: Guest | Views: 59
Total answers/comments: 1
Guest [Entry]

"In the general case, you should look for your SPECIFIC process in the process list, rather than something which just happens to have the same name.

We've previously been bitten by bugs where a process with the same (or similar) name appears and breaks something (usually a monitor or start/stop script, so it's not usually vital).

Your process should write a pid file when it starts up (or before, by having a shell script write its pid in then exec your task), and then you can refer to the contents of that pid file in a subsequent shell script.

To check if a specific pid is running, kill it with ""signal 0"" - this doesn't actually send a signal just checks that it is there."