Thinking about when our crontab entries run

November 6, 2021

It's clock change time tonight in Canada, so naturally when our crontab entries run is a little bit on my mind. This has led me to realize that almost all of our system crontab entries can be divided into two broad types.

The first sort of crontab entry is one that we want to run periodically at some interval (roughly, it doesn't have to be exact, especially for the longer intervals). We have ones that run every minute, every other minute, every five, ten, or fifteen minutes, every hour, and 'a few times a day'. These crontab entries mostly care about the elapsed time since the last time they ran; what the clock on the wall says is pretty irrelevant.

The second sort of crontab entries is that we want to run once a day or once a week at some time during low usage hours. When exactly these entries run during that time isn't all that important (we don't really care if it runs at midnight, 3am, or 6am), and so we often take the system defaults for 'once a day' timing. When we explicitly schedule these (usually because they want to run as a non-root user), we naturally avoid the 1am to 2am time change danger zone.

(I sometimes do wish all of our systems could agree on the 'once a day' time, and perhaps have it very close to midnight for the convenience of rolling logs. Having your daily logs run from roughly 6am one day to roughly 6am the next day does have its little drawbacks and discontents.)

We have a certain number of crontab entries that we want to run at specific times. Some of these times are based on work hours (for example, for making regular ZFS snapshots of some filesystems), and some times are chosen to be out of work hours but not too late (for when we start backups). There's generally some flexibility in when exactly we run the crontab, but they're fundamentally not in the 'once a day, when convenient' bucket because they have additional constraints.

I'm sure there are environments where system crontab entries need to run at specific narrow times dictated by business needs and other external events. We're just lucky enough to not be in one.

(We don't have any 'once a month' system crontab entries, although our Ubuntu machines have some of their own.)


Comments on this page:

By Joseph at 2021-11-07 06:15:18:

I’ve been doing operations work for about a decade now. I’ve used cron a lot. Aside from the syntax, which I’ve always found baroque, I didn’t think about them much. For the job they do, they do okay. However, In the last few years, I’ve started using systemd timers and found them to be a significant improvement over cron.

Would you ever consider switching?

Written on 06 November 2021.
« If we use PyPy, we'll likely use our own install of it
Systemd timer units don't have much appeal for us (over crontab entries) »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sat Nov 6 23:38:44 2021
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.