Cron, anacron and the best unix we have

George Shuklin
OpsOps
Published in
1 min readJan 4, 2018

Computer interfaces of our ancestors bring me to the knee. Today I learned one more “amazing” of it. It called ‘cron.daily’. (hourly and so on).

Expectations: you put your scripts there and they will be executed as root every daily, hourly, etc.
Reality: it’s complicated.

  1. Cron.daily, weekly, monthly may be executed by anacron or by run-parts.
  2. Cron.hourly is handled only by run-parts and follow cron limitations.
  3. If you restart your machine or restart cron (due to package upgrade, etc) you may have your .daily, .weekly and .monthly executed, or may be not, depending or anacron availability. Moreover, anacron execution may be delayed up to 24 hr, so you will eventually have your weekly/monthly job been executed (one day later) but you may miss one of your daily. If you restart machine/cron at a bad moment you will (for sure) loose your hourly jobs (as they are handled only by cron/run-parts).
  4. If your script have period (dot) in its filename, it will be silently ignored (not a bug, just a convenient feature for a job security of sysadmins granddads).
  5. None of those (1–4) non-runs will be logged.
  6. None of run-parts errors will be logged (f.e. Exec format error) message will be silently disposed.

I really want to migrate all that madness to systemd timers ASAP…

--

--

George Shuklin
OpsOps

I work at Servers.com, most of my stories are about Ansible, Ceph, Python, Openstack and Linux. My hobby is Rust.