Sometimes instead of running a permanent daemon you want a script to kick in
in regular intervals, do its job and then terminate. This way
it's not susceptible to memory growth, unreclaimed file handles and other
issues badly programmed scripts run into when run 24 hours a day without
restart.
If you run a script e.g. every minute from the cron, however, and it takes
more than 60 secs to complete, there's going to be 2 instances of the same
script potentially interfering with each other.
Enter CronDaemon. It will make sure that at all times, there's only one
instance of the script. If an instance hangs, and therefore prevents a
script restart for a configurable number of rounds, the new instance will
kill the old one and step in its place.
sleep(10); # This is our application
# PID file will be erased automatically if $cd goes out of scope
CronDaemon is Log::Log4perl enabled. If you turn on logging in
the CronDaemon category, you'll see logging statements according to
your Log::Log4perl settings.
Copyright 2002 by Mike Schilli, all rights reserved.
This program is free software, you can redistribute it and/or
modify it under the same terms as Perl itself.