A crontab command for Flatcar Container Linux, written in bash, that needs nothing beyond what Flatcar ships.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.0 KiB

flatcar-crontab

A crontab command for Flatcar Container Linux, written in bash, that needs nothing beyond what Flatcar ships.

Flatcar has no cron, and no official or sysext-bakery extension provides one. This wrapper lets scripts that call crontab run unchanged: each crontab line becomes a systemd --user timer and service for the calling user.

Install

sudo install -D -m 0755 crontab /opt/bin/crontab
sudo loginctl enable-linger core   # the user that owns the crontab

/opt/bin must be on the PATH of whatever calls crontab. Linger keeps the user's timers running without a login session.

Usage

crontab FILE      # replace the crontab from a file
crontab -         # replace the crontab from stdin
crontab -l        # print it
crontab -r        # remove it

There is no crontab -e: edit a file and install it.

Checking jobs

systemctl --user list-timers --all
journalctl --user -u crontab-job-3

Jobs are numbered in crontab order.

Files

Path Content
~/.config/crontab-timers/crontab The installed crontab
~/.config/crontab-timers/jobs/N.sh The command of job N
~/.config/systemd/user/crontab-job-N.{timer,service} Generated units

Supported schedules

Five fields, each *, */n, a value, a-b, a-b/n or a comma list. Month and weekday names work. Weekdays do not accept steps, and a weekday range must be ascending (0-2, not 5-1).

These are refused, and the installed crontab is left as it was:

  • @daily and other @ schedules
  • VAR=value lines
  • Unescaped % (\% is accepted and becomes %)
  • Restricting both day-of-month and weekday: cron ORs them, systemd ANDs them

Differences from cron

  • A run that comes due while the previous one is still active is skipped, not started alongside it.
  • There is no mail; capture job output yourself, for example with logger.
  • Runs missed while the machine was off are not caught up, as in cron.
  • Times follow the host's time zone, which is normally UTC on Flatcar.