brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl -u cron shows when each cron job started

Cron
~/tips/tip-cron-journalctl-unit-cron

journalctl -u cron --since today

Lists the log lines that prove whether cron started a given job and at what time.

Before debugging a job it helps to know whether cron started it at all.

journalctl -u cron --since today
grep CRON /var/log/syslog | tail

Each start produces a line like (jordi) CMD (/usr/local/bin/sync.sh), so a missing line means cron never ran the job and a present line means the problem is inside the command. Cron logs the start of a job, not its output. The unit is called cron on Debian and Ubuntu and crond on RHEL-based systems. The syslog file only exists when rsyslog is installed, while the journal always has the entries.

Further reading: journalctl manual page

Going deeper: Guide: find out why a Linux service failed, with journalctl

More Cron tips echo 'systemctl restart myapp' | at 03:00 tomorrow 55 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/month-end.sh EDITOR=nano crontab -e 30 6 * * mon /usr/local/bin/weekly-report.sh @daily /usr/local/bin/backup.sh All Cron tips (32) All topics

Link