Cron Expressions Guide: Scheduled Tasks
Cron is a tool that automatically runs scheduled tasks at specific time intervals in Unix/Linux systems. This guide covers cron expressions and their use cases.
Last updated:What is cron?
Cron is a scheduler that runs commands or scripts at specific time intervals. Used for system maintenance, backup, report generation, and automated notifications.
Cron expression contains 5 fields: minute (0-59), hour (0-23), day (1-31), month (1-12), day of week (0-7, 0 and 7 = Sunday).
Example: '0 3 * * 1' = Run every Monday at 03:00. '*/15 * * * *' = Run every 15 minutes. '0 0 1 * *' = Run at 00:00 on the 1st of every month.
Creating cron expressions
Asterisk (*): Every value. '0 * * * *' = Run at the start of every hour.
Comma (,): Multiple values. '0 9,12,15 * * *' = Run at 09:00, 12:00, and 15:00.
Hyphen (-): Range. '0 9-17 * * *' = Run every hour from 09:00 to 17:00.
Slash (/): Step. '*/10 * * * *' = Run every 10 minutes. '0 */2 * * *' = Run every 2 hours.
Question mark (?): 'Any' for day or day of week (in some cron implementations).
Common use cases
Backup: '0 2 * * *' = Take database backup every night at 02:00.
Report generation: '0 8 * * 1' = Generate weekly report every Monday at 08:00.
Cache clearing: '0 */6 * * *' = Clear cache every 6 hours.
Email notifications: '0 9 * * 1-5' = Send reminder email every weekday at 09:00.
SSL renewal: '0 3 * * *' = Check SSL certificate renewal every night at 03:00.
Utilgo cron expression explainer
Utilgo Cron Expression Explainer converts cron expressions into human-readable descriptions. Shows what each field means and calculates next run times.