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

Re: Creating a randomized cron entry



On Thu, Dec 15, 2005 at 11:07:17PM +0100, Florian Weimer wrote:
> I mainly want to avoid a scenario where all clients arrive at 17
> minutes past the full hour, and need to be served at the same time.

Then I would go for a cron entry at the earliest time you want the
script to be run (say 6:00 AM) which does something like

SHELL=/bin/bash
0 6 * * * root sleep $(( $RANDOM % max_gap )) ; your_command

Where max_gap is the number of seconds corresponding to the latest time
you want your script to be run - 6:00 AM.

Cheers.

-- 
Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. -!-

Attachment: signature.asc
Description: Digital signature


Reply to: