What is a Cron Expression?
A cron expression is a string of five or six fields that defines a recurring schedule for automated tasks. Used in Unix-based systems, cron jobs run scripts, backups, and processes at specified intervals without manual intervention. The standard five-field format controls minute, hour, day of month, month, and day of week.
Cron Expression Syntax Explained
| Field | Allowed Values | Special Characters |
|---|---|---|
| Minute | 0-59 | * , - / |
| Hour | 0-23 | * , - / |
| Day of Month | 1-31 | * , - / L |
| Month | 1-12 | * , - / |
| Day of Week | 0-6 (Sun=0) | * , - / |
Common Cron Expression Examples
| Expression | Meaning |
|---|---|
| * * * * * | Every minute |
| 0 * * * * | Every hour on the hour |
| 0 0 * * * | Every day at midnight |
| 0 9 * * 1-5 | Every weekday at 9am |
| 0 0 1 * * | First day of every month |
| 0 0 * * 0 | Every Sunday at midnight |
Frequently Asked Questions
What does * mean in a cron expression?
An asterisk means "every valid value" for that field. For example, * in the hour field means every hour. It is the wildcard character in cron syntax.
What is the difference between */5 and 5 in cron?
5 means "at exactly the 5th unit" (e.g. the 5th minute past the hour). */5 means "every 5th unit" — so at 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55.
Can cron run a job every 30 seconds?
Standard cron only resolves to one-minute precision. To run tasks more frequently than every minute, you would need to chain commands within a cron job or use a different task scheduler.
How do I test if my cron expression is correct?
Use this visual generator and verify the human-readable description matches your intent. You can also check server logs after the first scheduled run to confirm execution.