Skip to content

Instantly share code, notes, and snippets.

@weshouman
Created May 31, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weshouman/14ce4c24608c76c01f77d9f8b172b1ac to your computer and use it in GitHub Desktop.
Save weshouman/14ce4c24608c76c01f77d9f8b172b1ac to your computer and use it in GitHub Desktop.
A guide to crontab

Adding jobs

  • crontab -e: then add a line representing the job

Syntax

  • @reboot sleep 60 && my_script.sh
  • 59 12 * * * simon /usr/bin/sample.sh > /dev/null 2>&1

Known issues

  • silent failures: running a job with no permission for the current user fails silently, be careful to provide sudo when needed

Debug

  • Either sudo systemctl status crond or sudo systemctl status cron.service: Show recent systemd logs
  • Either journalctl --unit crond -n all or journalctl --unit cron -n all: Show all systemd logs Other ways
  • journalctl _COMM=cron
  • cat /var/log/syslog | grep crontab On some systems the logs are stored in /var/log/cron
  • cat /var/log/cron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment