Quote:
Originally Posted by GoogleMeister
how about: "ps -ef | grep (processID or processname)" imbedded into the code. If no lines returned, then you can be pretty sure that it ain't runnin'. I have run into situations where I needed to know not if a process was running, but rather how many instances were running. For that I shell scripted "ps -ef | grep (processID or processname) | wc -l".
Maybe a bit off track, but I hope it helps.
|
Unless it catches it's own grep.... I've run into that often enough.
Code:
latch@afx:~$ ps -ef | grep tomato
latch 24337 24325 0 18:12 pts/457 00:00:00 grep tomato
latch@afx:~$
gotta grep out the grep.. i.e.:
ps -ef | grep proccessIDorprocessName | grep -v grep
Then you can pipe to wc -l or whatever you'd like hehe.
Code:
latch@afx:~$ ps -ef | grep bash
latch 8370 1 0 Aug12 ? 00:00:00 /bin/bash /usr/bin/thunderbird
latch 25518 1 0 Aug14 ? 00:00:00 /bin/bash ./restartScript
latch 24020 1 0 17:59 ? 00:00:00 /bin/bash /usr/bin/firefox
latch 24325 24323 0 18:12 pts/457 00:00:00 -bash
latch 24434 24325 0 18:15 pts/457 00:00:00 grep bash
latch@afx:~$ ps -ef | grep bash | grep -v grep
latch 8370 1 0 Aug12 ? 00:00:00 /bin/bash /usr/bin/thunderbird
latch 25518 1 0 Aug14 ? 00:00:00 /bin/bash ./restartScript
latch 24020 1 0 17:59 ? 00:00:00 /bin/bash /usr/bin/firefox
latch 24325 24323 0 18:12 pts/457 00:00:00 -bash
latch@afx:~$ ps -ef | grep bash | grep -v grep | wc -l
4
latch@afx:~$