Re: Cron - any advanced options?
On Thu, Apr 23, 2009 at 09:29:29AM +0100, Dave Ewart wrote:
> Don't make it cron's responsibility to check whether the script is
> already running. Make it the *scripts's* responsibility.
Agreed. If you make cron responsible for making sure it doesn't run
twice, what happens when someone decides they should (for whatever
reason) run it from the command line, a web-based tool, or anything
other than cron?
> For example, the script should create a marker file (or similar) when it
> runs, deleting the marker file upon completion.
Depending on the script, you may also be able to accomplish this with ps
instead:
ps ax | grep [m]y-script-name
If it returns anything, then at least one process named "my-script-name"
is already running, so abort. (The [brackets] around the first letter
of my-script-name are to prevent "grep my-script-name" from appearing in
the output and creating a false positive.)
--
Dave Sherohman
NomadNet, Inc.
http://nomadnetinc.com/
Reply to: