See if another process is running

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

See if another process is running Sat Oct 06, 2012 2:24 pm • by HackerJL
I am using hazel a lot for handbrakecli. Thats great, its working.

I have a rule that runs whenever a file hits the folder with a certain extension. However, I dont want this rule to run if there is already another process running. How can I have it check that a process is running.

I understand I can have it so it passes a shell script, and I see that if it exits with status 0, it indicates a match.

So I run the command:
ps aux | grep HandBrakeCLI | wc -l

which responds with 1, since it finds its own grep command. So I want it to not return that, it should be 0

Further...is that the exit status or just a count. If its the count of 0, that deoesnt satisfy the 'passing' of the shell script.

Any help appreciated.
HackerJL
 
Posts: 31
Joined: Thu Sep 22, 2011 6:28 pm

Re: See if another process is running Mon Oct 08, 2012 11:22 am • by Mr_Noodle
You need to interpret that output and add your own exit statement with 0 if the output of the ps... stuff is correct to you. Note that what is output is not the exit code. Do "echo $?" immediately after executing a statement if you want to view what the exit code was. I also suggest searching for a shell script tutorial on this stuff.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion

cron