This one time, at band camp, Don Armstrong said: > On Thu, 15 Dec 2005, Florian Weimer wrote: > > I'd like to create a cron entry which is run once a day, at some > > random time. This is necessary because the cron entry will result > > in a request over the network, and I want to avoid that all hosts in > > a time zone pound the server at the same time. > > Why not just something like: > > 0 0 * * * at now + $(( $RANDOM \% 1440 )) minutes [...] Because that's a bashism, and some dash user will get upset with you. 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. Take care, -- ----------------------------------------------------------------- | ,''`. Stephen Gran | | : :' : sgran@debian.org | | `. `' Debian user, admin, and developer | | `- http://www.debian.org | -----------------------------------------------------------------
Attachment:
signature.asc
Description: Digital signature