views:

27

answers:

1

Hi guys!

I want to setup rake tasks to run via cron. That is easy, but what is not easy is ensuring that only one copy of that rake task is running at a time. I imagine I could use ps on the system to check and then exit the rake task if it is already running, or I could do a delayed job structure where I serialize the name of the task and upon completion I remove it form the DB, but what do you all recommend?

A: 

Unix solved this issue with pid files. Pid files are located in /var/run and contain the programs process Id. Here is the man page: http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?pidfile+3

You might find it a bit old fashioned (and I agree), but it's an often used and proven method.

Johan
That looks very good, actually! I can't find any good tutorials on how to to effectively use it, so I am going to take the DelayedJob method of checking PID files and use it for my purposes. Thank you.
tesmar