Expression Builder
Every 5 minutes
Presets
Next 10 Run Times
Computed in your local timezone ().
How Cron Works
Cron is a time-based job scheduler on Unix-like systems. Each line in a crontab file represents one scheduled job, written as a five-field expression followed by the command to run.
┌───── minute (0 - 59) │ ┌─── hour (0 - 23) │ │ ┌─ day of month (1 - 31) │ │ │ ┌─ month (1 - 12) │ │ │ │ ┌─ day of week (0 - 6, Sunday = 0) │ │ │ │ │ * * * * * command to be executed
Operators
| Symbol | Meaning | Example | Reads as |
|---|---|---|---|
* | Any value | * * * * * | Every minute |
, | Value list | 0,15,30,45 * * * * | At :00, :15, :30, :45 |
- | Range | 0 9-17 * * * | Every hour 9am–5pm |
/ | Step | */10 * * * * | Every 10 minutes |
a-b/n | Stepped range | 0 8-18/2 * * * | Every 2h between 8–18 |
Common Examples
| Expression | Schedule |
|---|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
0 * * * * | Every hour on the hour |
0 9 * * * | Every day at 9:00 AM |
0 9 * * 1-5 | Weekdays at 9:00 AM |
0 0 * * 0 | Sundays at midnight |
0 0 1 * * | First day of every month |
30 2 * * 1 | Mondays at 2:30 AM |
0 */6 * * * | Every 6 hours |
Editing Your Crontab
# List current jobs crontab -l # Edit (opens your $EDITOR) crontab -e # Remove all jobs for current user crontab -r # Install from a file crontab myjobs.txt # Run as another user (needs root) sudo crontab -u deploy -e
Best Practices
- Use absolute paths for commands and files — cron runs with a minimal
PATH. - Redirect output to a log:
/usr/bin/mytask >> /var/log/mytask.log 2>&1 - Set environment at the top of the crontab (
SHELL=/bin/bash,PATH=...) — cron does not source your shell profile. - Avoid overlap for long jobs: wrap with
flock -n /tmp/job.lock -c '...'. - Double-check day-of-month vs day-of-week — when both are specified (not
*), cron fires when either matches. - Test first: run the command manually, then schedule a frequent run (
* * * * *) while debugging.
Special Strings
| Shortcut | Equivalent |
|---|---|
@yearly / @annually | 0 0 1 1 * |
@monthly | 0 0 1 * * |
@weekly | 0 0 * * 0 |
@daily / @midnight | 0 0 * * * |
@hourly | 0 * * * * |
@reboot | Runs once at system startup |