Bash: check if process is running
Posted on 2009-12-17
I'm trying to make a bash script to check if Firefox is running. If not, then I would like to start it.
So far, I have the following:
APPCHK=$(ps aux | grep -c $APP1)
But I'm not sure about the return codes. I'd be grateful if someone could help.
The command /usb/bin/firefox will start Fx the way I want, but I think I also need to export the DISPLAY variable before hand. How do I do that in bash? This is how I'd do it from the command line:
$ export DISPALY=:0
Also, do I need to exit the bash script once Firefox is running, because normally, if I start Fx from command line I need do use something like following so that I can close my terminal session without shutting down Fx again:
$ ssh user@localhost -f -X firefox