]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
cron(8): schedule interval jobs that get loaded during execution
authorkevans <kevans@FreeBSD.org>
Sat, 20 Apr 2019 02:54:20 +0000 (02:54 +0000)
committerkevans <kevans@FreeBSD.org>
Sat, 20 Apr 2019 02:54:20 +0000 (02:54 +0000)
commit5ed19439979ca3af9608225171ed03af4332b11e
tree27e5a3c990f4d744fea193a68c357bc00e08d614
parente8785956785db49b5328cfb5368d57c51fc6ddb3
cron(8): schedule interval jobs that get loaded during execution

Jobs using the @<second> syntax currently only get executed if they exist
when cron is started. The simplest reproducer of this is:

echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob

myjob will get loaded at the next second==0, but this echo job will not
run until cron restarts. These jobs are normally handled in
run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup
time so they run 'n' seconds later.

Fix this by special-casing TargetTime > 0 in the database load. Preexisting
jobs will be handled at startup during run_reboot_jobs as normal, but if
we've reloaded a database during runtime we'll hit this case and set
e->lastexit to the current time when we process it. They will then run every
'n' seconds from that point, and a full restart of cron is no longer
required to make these jobs work.

Reported by: Juraj Lutter (otis_sk.freebsd.org)
Reviewed by: allanjude, bapt, bjk (earlier version), Juraj Lutter
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19924
usr.sbin/cron/cron/database.c
usr.sbin/cron/crontab/crontab.5