Is there a combination of command-line options for
pgrep or some other relatively direct way to determine if a particular process name is actually running (available for normal use)..
By "running", I mean to specifically exclude processes which are
<defunct> or any other non-running processes (eg. zombies :)...
This sample script shows an example of
#!/bin/bash ubuntu 10.04 pgrep ^gnuserv$ # 25591 # 25599 # 27330 ps $(pgrep ^gnuserv$) # command ammended as per pilcrow's good suggestion # PID TTY STAT TIME COMMAND # 25591 ? Zs 0:00 [gnuserv] <defunct> # 25599 ? Zs 0:00 [gnuserv] <defunct> # 27330 pts/2 S+ 0:00 gnuserv
I could further
sed the output, but I think/hope there's a more direct way...