Run a job every 2 hours
The cron expression for every 2 hours is 0 */2 * * *. The */2 step in the hour field fires at 00:00, 02:00, 04:00 and every even hour through 22:00, 12 times a day. Keep the 0 in the minute field: * */2 * * * runs every minute during those hours.
0*/2***Next 5 runs
Vercel always runs schedules in UTC, and GitHub Actions does unless you set a time zone. Crontab and Kubernetes use the server's time zone.
Field by field
0Minute- At minute 0
*/2Hour- Every 2nd hour: 0, 2, 4 … 22
*Day of month- Every day of the month
*Month- Every month
*Day of week- Every day of the week
By platform
Most schedulers take the same five fields. The wrapper, time zone and limits differ.
# m h dom mon dow command
0 */2 * * * /usr/local/bin/sync.sh >> /var/log/sync.log 2>&1Runs in the server's local time zone
on:
schedule:
- cron: "0 */2 * * *"Runs in UTC unless you set a time zone
timezone next to cron to use local time. Runs often start late when GitHub is busy, most of all at the start of an hour. In a public repository, GitHub turns the schedule off after 60 days without activity.spec:
schedule: "0 */2 * * *"
timeZone: "Etc/UTC"
concurrencyPolicy: ForbidWithout timeZone, the controller's zone applies
aws events put-rule \
--name sync-every-2-hours \
--schedule-expression "cron(0 0/2 * * ? *)"Six fields, and one day field must be ?
? in day-of-month or day-of-week. For a plain interval, rate(2 hours) is simpler, though its runs are timed from when you create the rule rather than by the clock.{
"crons": [
{ "path": "/api/sync", "schedule": "0 */2 * * *" }
]
}Needs a paid plan
Other 2-hour schedules
The step counts from midnight, not from when the job was installed. Start the range at 1 for odd hours, or change the minute to move runs off the hour.
| Expression | Runs |
|---|---|
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * | Same as 0 */2 * * *, with the hours listed |
0 1-23/2 * * * | Every 2 hours on the odd hours, 01:00 through 23:00 |
30 */2 * * * | Every 2 hours at half past, 00:30 through 22:30 |
0 8-18/2 * * 1-5 | At 08:00, 10:00, 12:00, 14:00, 16:00 and 18:00, Monday through Friday |