[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Creating a randomized cron entry



This one time, at band camp, Justin Pryzby said:
> On Thu, Dec 15, 2005 at 12:55:00PM +0000, Stephen Gran wrote:
> > 
> > Probably the most portable way to handle it is to run the job from
> > cron.daily, but call a wrapper script that sleeps for a random amount of
> > time less than one day before runnign the actual job.  For extra
> > goodness, use a lock file so that if the last random sleep was 23 hours
> > and 59 minutes, and the next one is 1 minute, you don't two jobs at
> > once.
> But that means essentially running a daemon for the package,
> completely undermining the point of cron.

Except that it doesn't fork to the background, close file descriptors,
or handle requests.  Basically it would do 

sleep $RANDOM
touch lock.tmp
if ln lock.tmp lock 2>/dev/null; then 
  rm -f lock.tmp
  run program
  rm -f lock
else
  rm -f lock.tmp
fi

Not much a daemon, if you ask me (unless your definition of daemon is
anything that uses a timer and sleep).
-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        sgran@debian.org |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature


Reply to: