Crontab Every 5 Minutes (*/5 * * * *)
Schedule a cron job to run every 5 minutes using the step value syntax. One of the most commonly used cron expressions for monitoring and polling.
Detailed Explanation
Running a Cron Job Every 5 Minutes
The expression */5 * * * * uses the step operator (/) in the minute field. The */5 means "starting at 0, every 5th minute," so the job runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55 of every hour.
Field Breakdown
| Field | Value | Meaning |
|---|---|---|
| Minute | */5 | Every 5th minute |
| Hour | * | Every hour |
| Day of Month | * | Every day |
| Month | * | Every month |
| Day of Week | * | Every day |
Understanding the Step Operator
The / character is called the "step" or "skip" operator. When combined with *, it starts from the minimum value of the field (0 for minutes) and increments by the step value:
*/5in the minute field = 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55*/10in the minute field = 0, 10, 20, 30, 40, 50*/15in the minute field = 0, 15, 30, 45
You can also combine a range with a step: 10-50/5 means every 5 minutes starting at minute 10, up to minute 50.
Execution Frequency
This expression triggers 288 times per day (12 times per hour x 24 hours), which is a good balance between responsiveness and resource usage.
Example
*/5 * * * * curl -s https://example.com/api/status | logger -t monitor
Use Case
The 5-minute interval is the most popular polling frequency. Use it for API health checks, cache invalidation, syncing data between services, updating dashboards, or checking for new messages in a queue.