Cron Cheatsheet - Cron Expression & Task Scheduling Reference

All essential Cron commands organized by use case, with 43+ entries you can copy and run directly. Find the right command fast when you need it.

SysOps·43 commands·Last updated 2026-07-21
Back to SysOps

Expression Format 6

* * * * * command
Standard format: 5 fields (minute hour day month weekday)
Minute (0-59)
Field 1: minute of the hour (0-59)
Hour (0-23)
Field 2: hour of the day (0-23); 0 is midnight
Day of month (1-31)
Field 3: day of the month (1-31)
Month (1-12)
Field 4: month of the year (1-12)
Day of week (0-7)
Field 5: day of the week (0 and 7 both mean Sunday; 1-6 are Mon-Sat)

Special Characters 6

*
Any value; no restriction on this field
*/N
Every N units, e.g. */5 means every 5 minutes
A-B
Range, e.g. 9-17 means every unit from 9 to 17
A,B,C
List, e.g. 1,3,5 means Monday, Wednesday, Friday
A-B/N
Step within a range, e.g. 1-10/2 means 1,3,5,7,9
L
Last, e.g. 0 0 L * * runs on the last day of the month (supported by some implementations)

Special Time Macros 6

@reboot
Run once at system startup; commonly used to start background services
@yearly / @annually
Run once a year, equivalent to 0 0 1 1 *
@monthly
Run once a month, equivalent to 0 0 1 * *
@weekly
Run once a week, equivalent to 0 0 * * 0
@daily / @midnight
Run once a day, equivalent to 0 0 * * *
@hourly
Run once an hour, equivalent to 0 * * * *

Common Examples 8

*/5 * * * * command
Run every 5 minutes
0 * * * * command
Run at the top of every hour
0 3 * * * command
Run daily at 3 AM
0 0 * * 1 command
Run weekly on Monday at midnight
0 0 1 * * command
Run monthly on the 1st at midnight
0 9-18 * * 1-5 command
Run every hour on weekdays from 9 AM to 6 PM
*/30 * * * * command
Run every 30 minutes
0 0 * * 0 command
Run weekly on Sunday at midnight

Environment Variables 6

SHELL=/bin/bash
Shell used to execute cron commands
PATH=/usr/local/bin:/usr/bin:/bin
Command search path; cron's default PATH is minimal
MAILTO="admin@example.com"
Send command output via email to the given address
MAILTO=""
Disable email notifications (send no output)
HOME=/home/user
Set the HOME directory for execution
CRON_TZ=Asia/Shanghai
Set the timezone cron uses

Permissions 6

/etc/cron.allow
Whitelist: only users listed here may use crontab
/etc/cron.deny
Blacklist: users listed here are forbidden from using crontab
crontab -u user -e
Edit a specific user's crontab (as root)
crontab -u user -l
Show a specific user's scheduled tasks
crontab -u user -r
Delete all of a specific user's scheduled tasks
ls /var/spool/cron/
Show where each user's crontab file is stored

Troubleshooting 5

grep CRON /var/log/syslog
Show cron execution logs on Debian/Ubuntu
grep cron /var/log/cron
Show cron execution logs on RHEL/CentOS
systemctl status crond
Check the cron service state (RHEL/CentOS)
systemctl status cron
Check the cron service state (Debian/Ubuntu)
* * * * * echo test >> /tmp/cron-test 2>&1
Debug: write a line every minute to test if cron works

Tips

  • cron's environment differs from an interactive shell; PATH may be incomplete — export PATH explicitly in your script if commands aren't found.
  • Use absolute paths for commands to avoid cron failing to locate executables, especially interpreters like node or python.
  • Output is emailed by default; redirect to a log file instead, e.g. command >> /var/log/job.log 2>&1.
  • Specifying both day-of-month and day-of-week is an OR relationship, not AND — 0 0 13 * 5 means the 13th OR every Friday.
  • No need to restart cron after editing crontab; changes take effect on save, but the script itself must be executable.
  • If both cron.allow and cron.deny exist, only allow is consulted; if neither exists, the distribution's default policy applies.

Official References

Commands are compiled from the official docs below. Click to verify the latest usage.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us