← Knowledge Base
BashReference note1 min read · updated 2026-11-27

Schedule jobs with cron

The five time fields, crontab editing, the system cron directories, and why jobs silently fail.

cronscheduling
# m  h  dom mon dow  command
  20 3  *   *   *    /usr/local/sbin/backup.sh >> /var/log/backup.log 2>&1
  */15 * * * *       /opt/check.sh
  0  9  *   *   1-5  /opt/weekday-report.sh
crontab -e            # edit your jobs
crontab -l            # list
sudo crontab -u www-data -l

Files in /etc/cron.d/ use the same format plus a user column (20 3 * * * root /path). Cron runs with a tiny environment: use absolute paths, set PATH at the top of the file and redirect output to a log. The server's clock is usually UTC. A script that works in your shell but not in cron nearly always has a PATH or permissions difference. On systemd systems, timers (systemctl list-timers) are the alternative.