SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Cron
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Cron cheatsheet

Crontab management

CommandDescription
crontab -eEdit current user's crontab
crontab -lList current user's crontab
crontab -rRemove current user's crontab
crontab -u user -lList another user's crontab (root)
sudo crontab -e -u www-dataEdit crontab as a specific user

Field syntax

FieldValuesExample
Minute0–59*/5 every 5 minutes
Hour0–232 at 02:00
Day of month1–311 first of the month
Month1–12* every month
Day of week0–7 (0 and 7 = Sunday)1-5 weekdays

Special strings

StringEquivalentMeaning
@reboot—Run once at startup
@yearly / @annually0 0 1 1 *Once a year
@monthly0 0 1 * *First day of month
@weekly0 0 * * 0Every Sunday
@daily / @midnight0 0 * * *Every day at midnight
@hourly0 * * * *Every hour

Common schedule examples

# Every day at 3:15 AM 15 3 * * * /usr/local/bin/backup.sh # Every 10 minutes */10 * * * * /opt/app/healthcheck.sh # Weekdays at 9 AM 0 9 * * 1-5 /usr/bin/report.sh # First of month at midnight 0 0 1 * * /usr/local/bin/monthly-cleanup.sh

System cron locations

PathDescription
/etc/crontabSystem-wide crontab (includes user field)
/etc/cron.d/Per-package drop-in files
/etc/cron.hourly/Scripts run hourly
/etc/cron.daily/Scripts run daily
/var/spool/cron/crontabs/User crontabs (Debian/Ubuntu)
/var/spool/cron/User crontabs (RHEL/CentOS)

Inspection & logs

CommandDescription
systemctl status cronCheck cron service (Debian/Ubuntu)
systemctl status crondCheck cron service (RHEL/CentOS)
grep CRON /var/log/syslogCron run log (Debian/Ubuntu)
grep CRON /var/log/cronCron run log (RHEL/CentOS)
journalctl -u cronsystemd journal for cron unit

Crontab environment lines

MAILTO=ops@example.com PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin SHELL=/bin/bash */5 * * * * /usr/local/bin/job.sh >> /var/log/job.log 2>&1

Pro tips

  • Always use absolute paths for scripts and binaries in cron jobs
  • Redirect output to a log file — cron won't show errors on your terminal
  • Use flock to prevent overlapping runs of the same job
  • Test the exact command as the cron user: sudo -u www-data /path/to/script.sh

Practice scenarios

Hands-on Cron scenarios on live Linux VMs: cron

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a