Cron every 2 hours
The cron expression 0 */2 * * * runs a job every 2 hours at minute 0, from 00:00 to 22:00. The next runs are 2026-11-27 04:00 and 2026-11-27 06:00 UTC. The shortest gap between runs is 2 hours, so a heartbeat monitor with a 30-minute grace period catches a missed run.
| minute | hour | day of month | month | day of week |
|---|---|---|---|---|
| 0 | */2 | * | * | * |
* */2 * * * is not every 2 hours. With * in the minute field it runs every minute of each matching hour (00:00-00:59, 02:00-02:59 …), 720 runs a day instead of 12. Keep a fixed minute: 0 */2 * * *.Next runs (UTC)
- Fri 2026-11-27 04:00 UTC (+00:00) · in 30m
- Fri 2026-11-27 06:00 UTC (+00:00) · in 2h 30m
- Fri 2026-11-27 08:00 UTC (+00:00) · in 4h 30m
- Fri 2026-11-27 10:00 UTC (+00:00) · in 6h 30m
- Fri 2026-11-27 12:00 UTC (+00:00) · in 8h 30m
- Fri 2026-11-27 14:00 UTC (+00:00) · in 10h 30m
- Fri 2026-11-27 16:00 UTC (+00:00) · in 12h 30m
- Fri 2026-11-27 18:00 UTC (+00:00) · in 14h 30m
- Fri 2026-11-27 20:00 UTC (+00:00) · in 16h 30m
- Fri 2026-11-27 22:00 UTC (+00:00) · in 18h 30m
Notes for this schedule
0 1-23/2 * * *.This schedule in numbers
- Fires 12 times on each day it runs: 4,380 times in 2026.
- Converted to systemd:
OnCalendar=*-*-* 00/2:00:00, the line used in the timer below;systemd-analyze calendarprints its next elapse times so you can compare them with the list here. - On a UTC server the 12 daily runs land at 01:30, 03:30, 05:30, 07:30, 09:30, 11:30, 13:30, 15:30, 17:30, 19:30, 21:30, 23:30 India time (UTC+05:30, no daylight saving), the same all year.
- If the server's timezone were America/New_York: on Sunday 14 March 2027 the New York day is 23 hours long, so a server in that zone runs this schedule 11 times instead of 12 (wildcard schedules follow the wall clock).
Next 5 runs on a UTC server, with India time
| UTC | IST (UTC+05:30) |
|---|---|
| Fri 27 Nov 2026, 09:30 | |
| Fri 27 Nov 2026, 11:30 | |
| Fri 27 Nov 2026, 13:30 | |
| Fri 27 Nov 2026, 15:30 | |
| Fri 27 Nov 2026, 17:30 |
Examples
0 */2 * * * /usr/local/bin/my-job.sh && curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>
# /etc/systemd/system/my-job.timer [Unit] Description=Run my-job (every 2 hours) [Timer] OnCalendar=*-*-* 00/2:00:00 Persistent=true [Install] WantedBy=timers.target
# /etc/systemd/system/my-job.service [Unit] Description=my-job [Service] Type=oneshot ExecStart=/usr/local/bin/my-job.sh # runs only if ExecStart succeeded ExecStartPost=/usr/bin/curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>
Check the calendar spec with systemd-analyze calendar "*-*-* 00/2:00:00", then systemctl enable --now my-job.timer. Persistent=true runs a missed job at boot. Convert this schedule to Quartz or AWS cron() →
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "0 */2 * * *"
timeZone: "Etc/UTC" # Kubernetes 1.27+; otherwise the controller's timezone
concurrencyPolicy: Forbid # don't start a new run while one is active
startingDeadlineSeconds: 300 # still start if the controller was briefly down
jobTemplate:
spec:
backoffLimit: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: your-image:tag
command: ["/bin/sh", "-c", "/app/run-job.sh && curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>"]
on:
schedule:
- cron: "0 */2 * * *" # UTC unless you add timezone: under it
workflow_dispatch: {} # lets you run it by hand too
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./run-job.sh
- name: Tell Vigil the job ran
if: success()
run: curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/${{ secrets.VIGIL_PING_TOKEN }}
GitHub reads schedules in UTC unless the entry sets timezone: (an IANA name), can delay them at busy times, and disables scheduled workflows in public repos after 60 days without activity.
Common mistakes
timedatectl or date. cronie (RHEL, Fedora, Arch) accepts CRON_TZ=Asia/Kolkata at the top of a crontab; Debian/Ubuntu cron does not.0 0 13 * 5 runs on every 13th and every Friday, not only on Friday the 13th.% is turned into a newline (everything after it goes to the command's stdin). Write date +\%F, not date +%F.PATH (often just /usr/bin:/bin), no login shell and no .bashrc. Use absolute paths and set variables at the top of the crontab.How to get alerted when it doesn't run
A cron job that stops running looks exactly like one that's working: no errors, no output. The reliable fix is a heartbeat (dead man's switch): the job pings a URL each time it finishes, and the monitor alerts you when a ping is late.
- Create a heartbeat in Vigil and choose cron schedule: 0 */2 * * *, timezone of your server.
- Set a grace period of about 30 minutes: long enough for a normal run to finish, short enough that you hear about it quickly.
- Add the ping to the end of the command (above). && means only successful runs ping; use /ping/<token>/$? to report the exit code, and /start to catch jobs that hang.
Watch this schedule — get alerted if it doesn't run
More: how to monitor cron jobs (exit codes, run time, logs) · heartbeat monitoring, explained
Vigil tells you when a run is missed
Vigil heartbeats understand cron expressions and timezones, so they know exactly when each run is due. Missed, failed or stuck runs alert you on email, Slack, Telegram, Discord or a webhook, and the history shows every run's duration.