Check to see if a process is already running

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Check to see if a process is already running 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?
HackerJL
 
Posts: 31
Joined: Thu Sep 22, 2011 6:28 pm

You can try using something like:

ps -auwx | grep NAME OF PROCESS

where NAME OF PROCESS is the name of the process.
Mr_Noodle
Site Admin
 
Posts: 11280
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Check to see if a process is already running Sat Nov 19, 2011 9:05 pm • by sjk
I'd use "ps -acx …", as explained here.
sjk
 
Posts: 332
Joined: Thu Aug 02, 2007 5:43 pm
Location: Eugene

Ah yes, good point.
Mr_Noodle
Site Admin
 
Posts: 11280
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support