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

Re: Creating a randomized cron entry

Florian Weimer wrote:
> * Christoph Berg:
>>Re: Florian Weimer in <87acf223bk.fsf@mid.deneb.enyo.de>
>>>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.
>>I guess it is ok if you create a fixed entry for a machine, and the
>>different entries on different machines will then do the load
>>balancing. Just pick two random numbers and put them in /etc/cron.d/.
> Hmm, should the postrm script delete it during purge?  It's not a
> conffile, and I don't like changing files under /etc automatically.

You're not changing files under /etc automatically.

/etc/cron.d is a directory, and you're putting your own cronjob in
there. It's a config file that you're generating in the maintainer
scripts just the same way that you'd generate any other conffile in
response to debconf questions.

It might be nice to drop the admin a debconf note telling them you
generated a random cronjob (so they can change it if the computer won't
be up), possibly better if you specifically ask them what time they want
it, but you give it a random default. (I don't know if this last part is

>>Keep in mind that Debian users usually expect that daily cronjobs will
>>still be run if the machine is down at night and anacron is installed.
>>You might want to add an additional @reboot job.

You might have to look at how the daily cronjobs are run using anacron
(iff anacron is installed) when they are missed and replicate the
mechanism for yourself in your own package.

--Ken Bloom

I usually have a GPG digital signature included as an attachment.
See http://www.gnupg.org/ for info about these digital signatures.

Reply to: