Cron Syntax Explained With Practical Examples
Cron is the time-based scheduler behind countless backups, reports and cleanup jobs. Its five-field syntax is compact but easy to misread, and a wrong schedule usually fails silently: the job simply runs at the wrong time or not at all. These examples cover the patterns you will use most.
Common schedules
Copy these and adjust the numbers:
*/5 * * * * every 5 minutes
0 * * * * every hour on the hour
30 2 * * * every day at 02:30
0 9 * * 1-5 weekdays at 09:00
0 0 1 * * first day of every month
0 0 * * 0 every Sunday at midnightSpecial characters
* means any value. A comma lists values (1,15). A hyphen sets a range (1-5). A slash sets a step (*/10 or 0-30/10). Some systems also accept names such as MON or JAN and shortcuts like @daily, but they are not universal.
Where cron runs
On Linux, edit your schedule with crontab -e. In Kubernetes, put the expression in the schedule field of a CronJob. In GitHub Actions, use on.schedule.cron, which always runs in UTC and can be delayed during busy periods.
on:
schedule:
- cron: '0 6 * * 1' # Mondays 06:00 UTCDebugging a job that does not run
Check the timezone first. Then remember cron uses a minimal environment: use absolute paths for commands and files, and redirect output to a log (>> /var/log/job.log 2>&1) so errors are visible.