Page MenuHomeFreeBSD

cron(8): schedule interval jobs that get loaded during execution
ClosedPublic

Authored by kevans on Apr 16 2019, 2:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 4:29 AM
Unknown Object (File)
Fri, Apr 5, 11:40 AM
Unknown Object (File)
Mar 12 2024, 10:14 AM
Unknown Object (File)
Mar 12 2024, 10:14 AM
Unknown Object (File)
Mar 12 2024, 10:14 AM
Unknown Object (File)
Mar 12 2024, 10:14 AM
Unknown Object (File)
Mar 8 2024, 5:34 AM
Unknown Object (File)
Dec 22 2023, 9:12 PM
Subscribers

Details

Summary

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 ever run. 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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 23695

Event Timeline

Revision has been tested and working properly.

This revision is now accepted and ready to land.Apr 16 2019, 3:32 PM
bjk added inline comments.
usr.sbin/cron/crontab/crontab.5
254

This is an error in the preexisting text, not your change, but while you're here, please s/scheduled specified amount/scheduled the specified number/

allanjude added inline comments.
usr.sbin/cron/crontab/crontab.5
248

"that many seconds after completion of the previous invocation of" is much more grammatically pleasing

253

It might be good to be more explicit here.

Might it overlap every time you reload cron, or is the only risk of overlap when you modify the file containing the @ entry?

254

"The first run is scheduled for the specified number of seconds after cron is started or the crontab entry is reloaded"

Does that sound better?

kevans marked 3 inline comments as done.

Take a shot at re-wording various bits based on feedback from @bjk and @allanjude

This revision now requires review to proceed.Apr 19 2019, 6:49 PM
usr.sbin/cron/crontab/crontab.5
253

How's this?

254

I think that flows pretty well.

This revision is now accepted and ready to land.Apr 19 2019, 8:53 PM
This revision was automatically updated to reflect the committed changes.