Pcornel
Linux · Scheduling

cron

Cheat sheet · https://pcornel.dk/topic.php?topic=2826

Back to the Topic

Answer

cron runs commands on a schedule from crontab entries: minute hour day-of-month month day-of-week command (e.g. 30 2 * * 1 /usr/local/bin/backup.sh).

Remember

Edit with crontab -e (user) or files in /etc/cron.d (with a user field). % must be escaped as \%. cron uses the system time zone. Output is mailed or lost unless redirected. Use crontab.guru or systemd-analyze calendar to check expressions.

First checks

  • systemctl list-timers --all — systemd timers and next run
  • crontab -l -u <user> — a user's cron jobs
  • ls /etc/cron.d /etc/cron.daily — system cron jobs
  • journalctl -u cron -u crond --since today — cron executions

Verify in this order

crontab entry → cron daemon checks every minute → matching time → command runs as the user → output mailed or redirected

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2826

Confirmation

Confirm action

Continue?