Cron Expression Syntax Cheatsheet 2026
Quick reference guide for UNIX Cron patterns: minute, hour, day, month, day-of-week, special strings, and automation schedules.
Field Meanings
When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
* * * * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
m h dom mon dowOutput Example
Cron entry updated in crontab (Schedules task execution sequence)Standard Schedules
When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 0 * * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 * * * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 0 * * 0Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 0 1 * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)Interval Schedules
When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
*/15 * * * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 9-17 * * 1-5Output Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When scheduling background cron jobs, task automation scripts, or recurring timers on UNIX servers.
Common Mistakes
Assuming five-field cron expressions behave identically in platforms that support six-field patterns (which include seconds).
Shortcut / Pro-Tip
Validate and preview your scheduling intervals using online visualizers like crontab.guru before deployment.Example
0 0,12 * * *Output Example
Cron entry updated in crontab (Schedules task execution sequence)Special Shortcuts
When to Use
When establishing standard, standard-interval schedules with highly readable shortcuts.
Common Mistakes
Assuming custom shortcuts like @reboot are supported by all basic cron implementations (some strictly require five fields).
Shortcut / Pro-Tip
Use '@daily' to quickly schedule log rotations or daily reports without writing number wildcards.Example
@rebootOutput Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When establishing standard, standard-interval schedules with highly readable shortcuts.
Common Mistakes
Assuming custom shortcuts like @reboot are supported by all basic cron implementations (some strictly require five fields).
Shortcut / Pro-Tip
Use '@daily' to quickly schedule log rotations or daily reports without writing number wildcards.Example
@hourlyOutput Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When establishing standard, standard-interval schedules with highly readable shortcuts.
Common Mistakes
Assuming custom shortcuts like @reboot are supported by all basic cron implementations (some strictly require five fields).
Shortcut / Pro-Tip
Use '@daily' to quickly schedule log rotations or daily reports without writing number wildcards.Example
@dailyOutput Example
Cron entry updated in crontab (Schedules task execution sequence)When to Use
When establishing standard, standard-interval schedules with highly readable shortcuts.
Common Mistakes
Assuming custom shortcuts like @reboot are supported by all basic cron implementations (some strictly require five fields).
Shortcut / Pro-Tip
Use '@daily' to quickly schedule log rotations or daily reports without writing number wildcards.Example
@weeklyOutput Example
Cron entry updated in crontab (Schedules task execution sequence)Cron Expressions Best Practices
1Always Specify Absolute Paths
The cron environment path is minimal. Always write absolute paths for commands (e.g., /usr/local/bin/node instead of node).
2Redirect Outputs to Log Files
Redirect standard output and error streams to custom log files (e.g., >> /var/log/myjob.log 2>&1) to audit and debug job failures.
3Double-Check Time Zone Alignments
Cron schedules execute based on system server time. Verify if your server runs on UTC, EST, or local zones before scheduling.
4Establish Lock-out Protection
Prevent overlapping job runs if a task takes longer than the schedule interval by wrapping the execution in 'flock'.
5Avoid Direct Root Cron Jobs
Configure cron jobs inside user-specific crontabs (crontab -e) rather than the global root system cron files to maintain security.
Common Cron Expressions Errors & Solutions
Cron job fails silently
Ensure your scripts have correct executable permissions (chmod +x) and all environment paths are declared absolutely.
E-mails spamming root mailbox
Redirect output to dev/null or files, or write 'MAILTO=""' at the very top of your crontab file.
Overlapping task executions
Use 'flock -n /tmp/myjob.lock /path/to/script.sh' to prevent subsequent runs from starting if the current run is still active.
Permission Denied when executing shell scripts
The cron daemon cannot execute the file. Grant executable rights: chmod +x /path/to/script.sh.
Commands work in terminal but fail in cron
Terminal profiles (.bashrc, .zshrc) are not loaded by cron. Manually source your profile or declare all environment variables at the top of the crontab.
Common Cron Expressions Interview Questions
Q1What is the standard format of a classic cron expression?
A classic cron expression consists of five fields: 'minute hour day-of-month month day-of-week' (e.g., '* * * * *').
Q2How do you edit and list cron jobs for the current logged-in user?
Use 'crontab -e' to edit the crontab file, and 'crontab -l' to list all currently scheduled cron jobs.
Q3What does '*/15 9-17 * * 1-5' represent in cron scheduling?
It represents running a task every 15 minutes, during working hours (9:00 AM to 5:59 PM), Monday through Friday.
Q4What is the difference between classic crontab and /etc/crontab?
User-specific crontabs (via crontab -e) do not contain a username column. The system-wide '/etc/crontab' includes an additional column specifying which user executes the command.
Q5How can you run a command once at startup using cron?
You can use the '@reboot' schedule nickname (e.g. '@reboot /path/to/script.sh') to instruct cron to run the script immediately after system boot.
Generated from LearnHubly Developer Cheatsheets
Access interactive sandbox tests, tools, and developer code bases at https://www.learnhubly.com