How to tell if a certain program is running?
Phillip Johnson
phillipj at ptd.net
Fri Jul 6 10:45:55 UTC 2007
On Fri, 6 Jul 2007 19:38:17 +0900
"Craig Hagerman" <craighagerman at gmail.com> wrote:
> I am wondering if there is a simple way to programatically tell if a
> given program is running. I want to write a bash script to check if a
> program is running, then if not start it.
>
> My first idea was to try to return grep the output from 'ps ax' but
> even if a program isin't running grep will return the request you just
> made. I am sure there is a more elegant way I don't know about.
>
> Craig
>
I have done this in the past.
ps ax | egrep <name> | egrep -v egrep
That removes the grep (-v select non-matching lines).
HTH
Phil
More information about the ubuntu-users
mailing list