Re: Crontab | random execution time
- Reply: Arthur Chance : "Re: Crontab | random execution time"
- In reply to: Jos Chrispijn : "Crontab | random execution time"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Mar 2022 14:14:54 UTC
On Mon, 7 Mar 2022 14:36:19 +0100 Jos Chrispijn <bsduser@cloudzeeland.nl> wrote: > Dear list, > I am trying to run a cron job, starting once every two hours and at > random minute in the half our of that cron scheme: > > SHELL=/bin/sh > PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/etc > 0~30 */2 * * * root /root/cronjobs/run_myjob > > Unfortunately it is running exactly on the hour instead of random > between 0-30 minutes. I'd expect that to run once a minute for the first thirty minutes of even numbered hours. The usual way to achieve what you want is to add a random sleep in front of the job, or just rely on cron's jitter feature which isn't usually set for that much spread and affects every job. -- Steve O'Hara-Smith <steve@sohara.org>