How to tell if a certain program is running?

Smoot Carl-Mitchell smoot at tic.com
Mon Jul 9 00:59:11 UTC 2007


On Sun, 2007-07-08 at 09:51 -0400, Zac Brown wrote:
> You could use pgrep which will return nothing if the process doesn't
> exist and if it does, then it will return the process id(s).

You can also just check the exit code. e.g.

if pgrep firefox >/dev/null 2>&1; then
	echo firefox running
fi
-- 
Smoot Carl-Mitchell
System/Network Architect
email: smoot at tic.com
cell: +1 602 421 9005
home: +1 480 922 7313




More information about the ubuntu-users mailing list