Is there a way to schedule my script?

Ian Kelly ian.g.kelly at gmail.com
Thu Dec 18 11:23:06 EST 2014


On Thu, Dec 18, 2014 at 5:37 AM, Juan Christian <juan0christian at gmail.com>
wrote:
> I read the cron doc, it's really simple to use, but one think I didn't
see out-of-the-box is a way to set a random time, like 'execute this in a
5~10 min interval', I can only set specific times like 'execute this each
minute, each hour, each 10min' and so on.
>
> I found a 'fix' for that using $RANDOM in the crontab. Another workaround
would be to set a fixed 5min interval in cron and inside my script have a
random int (0 or 1), when 0, the script doesn't execute and 1 it execute,
so that way I'd have a little 'randomness' that I need.
>
> Which approach would be the best?

What kind of random distribution of the time between executions are you
looking for? A random sleep lends itself easily to a uniform distribution.
The latter approach that you describe would result in a geometric
distribution.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141218/3443cce1/attachment.html>


More information about the Python-list mailing list