Crontab Twice a Day (0 0,12 * * *)
Run a cron job twice a day at midnight and noon using a comma-separated hour list. Useful for semi-daily data sync and batch processing.
Detailed Explanation
Running a Cron Job Twice a Day
The expression 0 0,12 * * * uses a comma-separated list in the hour field to run at two specific times: midnight (00:00) and noon (12:00).
Field Breakdown
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 |
| Hour | 0,12 | At midnight and noon |
| Day of Month | * | Every day |
| Month | * | Every month |
| Day of Week | * | Every day |
The Comma Operator
The comma (,) creates a list of values within a single field. In the hour field, 0,12 means "at hour 0 AND at hour 12." You can list as many values as needed:
0,6,12,18— Four times a day (every 6 hours)8,12,17— Three times during business hours0,8,16— Every 8 hours
Compared to Step Values
0 0,12 * * * is equivalent to 0 */12 * * * — both run every 12 hours starting from midnight. The comma syntax is more explicit and easier to read when the times are irregular (e.g., 0 9,17 * * * for 9 AM and 5 PM).
Example
0 0,12 * * * /scripts/sync-inventory.sh
This synchronizes inventory data twice daily — once after the midnight window and once at midday.
Use Case
Use twice-daily scheduling for data synchronization between systems, sending morning and evening digest notifications, running backup verification at two points in the day, or semi-daily cache refresh for content management systems.