What is a Cron Job?
A cron job is a scheduled task in Unix/Linux systems that runs automatically at specified intervals. Defined in the crontab (cron table) file, they're used for automated backups, report generation, database maintenance, API calls, and server monitoring.
The Cron Expression Format
A cron expression has 5 fields: MINUTE HOUR DAY MONTH WEEKDAY. Each field accepts specific values and wildcards:
*โ any value (every minute, every hour, etc.)*/nโ every n units (*/5 = every 5 minutes)a,bโ multiple values (1,15 = 1st and 15th)a-bโ range (1-5 = Monday through Friday)
Common Cron Job Use Cases
- 0 0 * * * โ Daily backup at midnight
- */5 * * * * โ API health check every 5 minutes
- 0 9 * * 1-5 โ Daily report email every weekday at 9am
- 0 0 1 * * โ Monthly invoice generation