Cron job every 12 hours
The crontab line for a job every 12 hours is 0 */12 * * *. It runs 2 times a day, 730 times a year. Edit it below to see the next runs in your time zone.
How 0 */12 * * * reads
The five fields are minute, hour, day of month, month and day of week. A star means every value.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | minute 00 |
| Hour | */12 | every 12th hour: 0, 12 |
| Day of month | * | every day of month |
| Month | * | every month |
| Day of week | * | every day of week |
For example, from Wednesday 6 January 2027 at 10:07 the next runs are: Wed 6 Jan 2027, 12:00; Thu 7 Jan 2027, 00:00; Thu 7 Jan 2027, 12:00; Fri 8 Jan 2027, 00:00; Fri 8 Jan 2027, 12:00.
What a job every 12 hours is for
Twice a day suits jobs that summarise or protect a day’s work: a database dump at midnight and noon, sending a morning and an evening report, or rotating API keys.
Common mistakes
- «*/12» in the hour field gives 00:00 and 12:00. For 08:00 and 20:00, write the hours: «0 8,20 * * *».
- A job that takes hours can still be running when the next one starts; use flock or check for a lock file.
The same schedule as a systemd timer
On systems with systemd, a timer can replace the crontab line: OnCalendar=0/12:00. Check it with systemd-analyze calendar "0/12:00", which prints the next run.
Know when it didn’t run
Cron doesn’t tell you when a job stops running. Add a heartbeat monitor with a period of 12 hours and end the line with a call to its URL, for example 0 */12 * * * /path/job.sh && curl -fsS -m 10 <ping URL>. If a ping is late by more than the grace time you set, you get an alert, and a call to the URL with /fail reports a failure at once.
What is the cron expression for a job every 12 hours?
0 */12 * * *. It runs 2 times a day, 730 times a year, on the server’s clock.
How do I run a job every 12 hours with systemd instead?
Create a timer with OnCalendar=0/12:00 next to a service that runs the job, then enable it with systemctl enable --now name.timer. Persistent=true also runs a run that was missed while the machine was off.