Page 1 of 1

Check to see if a process is already running

PostPosted: Thu Nov 17, 2011 1:04 pm
by HackerJL
I have a hazel script set to run an automator action, which is fine.

My automator script feeds a terminal command with variables, works great.

What I am worried about is that I would like hazel to NOT run the automator script if the process is already running. So I assume I would need to check via a shell script, to see if process X is already running. If so, dont run it.

If it is not, then run it. Can someone point me in the right direction for a shell script to see if a process is running?

Re: Check to see if a process is already running

PostPosted: Fri Nov 18, 2011 1:36 pm
by Mr_Noodle
You can try using something like:

ps -auwx | grep NAME OF PROCESS

where NAME OF PROCESS is the name of the process.

Re: Check to see if a process is already running

PostPosted: Sat Nov 19, 2011 9:05 pm
by sjk
I'd use "ps -acx …", as explained here.

Re: Check to see if a process is already running

PostPosted: Mon Nov 21, 2011 12:59 pm
by Mr_Noodle
Ah yes, good point.