Tim Connors
2012-02-14 03:13:40 UTC
For such a critical system component, why is cron so devilishly stupid?
1)
Hour and minute are backwards. I get bitten by this all the time,
particularly on days when I had to get up too early to do software
patching on a few dozen servers.
2)
For that matter, all the other time fields are backwards too. Must have
been written by an American. In the rest of the sane world, we start with
least significant and then work out way up to most significant (or the
reverse). Not go backwards and forward all over the shop.
3)
All the time fields are ANDed. Except day and month. So debian needs
this hack to run mdadm check on first sunday of the month:
57 0 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi
instead of this:
57 0 1-7 * 0 root if [ -x /usr/share/mdadm/checkarray ] ; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi
You have to go to extra effort to make it this bad. Why would you
possibly want the date field to be ORed with the day of week? Was vixie
on powerful drugs at the time?
4)
"cron reads the crontab file(s) every minute to see whether there have
been changes. Therefore, any change to its schedule will take effect
within one minute."
No, it reads the cron files every minute, and then applies the new
schedule the next minute? Ie, there's always a minimum of a 1 minute
delay to a schedule update, and up to 2 minutes. Why? Why would it not
just read the new times, and if there's an entry for the current minute,
act upon it instead of checking whether there was a job due the next
minute to apply in the next minute? Again, this requires special
kind of bodgery to get wrong.
Unfortunately, this crappy behaviour is well embedded in the standard
operation of cron, and can't be changed because it would break the
expected broken behaviour.
Can we define a new standard is-not-quite-cron?
This rant brought to you by yet another
"/tmp/crontab.uPh6Gi/crontab":24: bad hour
errors in crontab file, can't install.
Do you want to retry the same edit? (y/n)"
1)
Hour and minute are backwards. I get bitten by this all the time,
particularly on days when I had to get up too early to do software
patching on a few dozen servers.
2)
For that matter, all the other time fields are backwards too. Must have
been written by an American. In the rest of the sane world, we start with
least significant and then work out way up to most significant (or the
reverse). Not go backwards and forward all over the shop.
3)
All the time fields are ANDed. Except day and month. So debian needs
this hack to run mdadm check on first sunday of the month:
57 0 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi
instead of this:
57 0 1-7 * 0 root if [ -x /usr/share/mdadm/checkarray ] ; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi
You have to go to extra effort to make it this bad. Why would you
possibly want the date field to be ORed with the day of week? Was vixie
on powerful drugs at the time?
4)
"cron reads the crontab file(s) every minute to see whether there have
been changes. Therefore, any change to its schedule will take effect
within one minute."
No, it reads the cron files every minute, and then applies the new
schedule the next minute? Ie, there's always a minimum of a 1 minute
delay to a schedule update, and up to 2 minutes. Why? Why would it not
just read the new times, and if there's an entry for the current minute,
act upon it instead of checking whether there was a job due the next
minute to apply in the next minute? Again, this requires special
kind of bodgery to get wrong.
Unfortunately, this crappy behaviour is well embedded in the standard
operation of cron, and can't be changed because it would break the
expected broken behaviour.
Can we define a new standard is-not-quite-cron?
This rant brought to you by yet another
"/tmp/crontab.uPh6Gi/crontab":24: bad hour
errors in crontab file, can't install.
Do you want to retry the same edit? (y/n)"
--
Tim Connors
Tim Connors