Cron Expression Generator
๐ค Agent ReadyBuild, explain, and test cron schedule expressions
Cron Syntax Reference
โโโโโโโโโโโโโโ minute (0-59) โ โโโโโโโโโโโโโโ hour (0-23) โ โ โโโโโโโโโโโโโโ day of month (1-31) โ โ โ โโโโโโโโโโโโโโ month (1-12) โ โ โ โ โโโโโโโโโโโโโโ day of week (0-6, Sun=0) โ โ โ โ โ * * * * * * = every value */n = every n intervals n = specific value n,m = multiple values n-m = range of values
What is a Cron Expression?
A cron expression is a string consisting of five or six fields separated by white space that represents a set of times, normally as a schedule to execute some routine. It is widely used in Unix-like operating systems to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals using the cron daemon.
How to read a cron schedule
Minute Hour Day-of-month Month Day-of-week.- * (Asterisk): Indicates all possible values for a field. E.g., an asterisk in the hour time field would be equivalent to every hour.
- , (Comma): Used to separate items of a list. E.g., using "MON,WED,FRI" in the 5th field (day of week) means Mondays, Wednesdays and Fridays.
- - (Hyphen): Defines ranges. E.g., "9-17" indicates every hour between 9 AM and 5 PM inclusive.
- / (Slash): Specifies increments. E.g., "*/15" in the minute field means "every 15 minutes".
Common Cron Job Use Cases
- Database Backups: Scheduling daily or weekly database dumps to a secure location (e.g.,
0 2 * * *for 2:00 AM daily). - Log Rotation: Compressing and archiving old log files to free up disk space.
- Email Notifications: Sending out daily summaries or weekly newsletters to users.
- System Maintenance: Running cleanup scripts to delete temporary files or clear caches.
- Data Syncing: Pulling or pushing data between APIs on a regular interval (e.g.,
*/5 * * * *for every 5 minutes).
Frequently Asked Questions
What does 0 0 * * * mean?
It means the job will run at minute 0 past hour 0 (midnight) every single day. This is one of the most common cron schedules for daily tasks like backups or log rotation.
How do I run a cron job every 5 minutes?
Use the expression */5 * * * *. The */5 in the first field means "every 5th minute".
Are cron times in UTC or local time?
Cron runs based on the system time of the server where the cron daemon is executing. Often servers are set to UTC, but you should always verify your server's timezone configuration.
Can I schedule tasks down to the second?
Standard Unix cron does not support seconds. The smallest unit of time is 1 minute. If you need sub-minute scheduling, you would typically write a script that sleeps and loops, or use an advanced job scheduler like systemd timers or a specialized application runner.