Is there a way to programmatically launch a cron job script in a way that still uses the locking feature, so that it won't interfere with any scheduled run of the script that might already be executing and vice versa? (The situation is that I have a cron job that I'd occasionally like to force a run of in response to some user action on my site.) A Ruby specific answer would be nice, but not necessary. Thanks.
Cron job locking internally just works by creating a cronjob that looks like this:
/usr/local/bin/setlock -n /tmp/cronlock.UNIQUEID COMMAND
where UNIQUEID is a unique identifier for the job, and COMMAND is the original command.
I assume that the unique ID must be unique to the command and not to the run of the command. (i.e. every time I launch the same command, it should get the same ID, because that's what the locking is based on.) If that's the case, how do I find out what ID cron itself is using for a given job? (In order to prevent collisions between scheduled runs of the command and my manual invocations of it.)
Well after you setup the cron job in the web panel, login to shell and then use the crontab program of course.
Customer since 2000 openvein.org
Thanks. One more question: once I create a cron job through the Dreamhost panel, will its unique ID never change? Or might it change if I edit the job or something like that?
I dunno! It will probably will change if you edit it.
Thanks, to both of you. I'm continually amazed by how quickly the help comes, both here and directly from support. Dreamhost is, like, a dream host.
The unique ID should remain constant as long as you don't delete and recreate the job.