Run Jobs Every Two Hours on the Hour | CronBase

cron expression Standard
$ 0 */2 * * *

Every two hours on the hour.

The `0 */2 * * *` cron expression executes a task every two hours at the start of the hour (minute zero). It triggers at midnight, 2:00 AM, 4:00 AM, and so forth throughout the day, providing a consistent bi-hourly cadence ideal for high-frequency maintenance and continuous data processing pipelines.

Minute
0
Hour
*/2
Day of Month
*
Month
*
Day of Week
*
How it works

Next 5 Runs

  • in 1h 36m
  • in 3h 36m
  • in 5h 36m
  • in 7h 36m
  • in 9h 36m

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# System cron entry: 0 */2 * * * /usr/local/bin/sync_assets.sh
set -euo pipefail
LOCKFILE="/var/lock/sync_assets.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
    echo "Error: Asset synchronization job is already running." >&2
    exit 1
fi
echo "Starting bi-hourly asset synchronization..."
# Perform actual work
if ! /usr/local/bin/perform_sync; then
    echo "Error: Sync failed. Sending alert." >&2
    exit 2
fi
echo "Synchronization completed successfully."
Setup notes

Save this script to your server, make it executable with chmod +x, and add the entry 0 */2 * * * /path/to/script.sh to your system crontab using crontab -e.

Last verified:

Partner BetterStack

Monitor this schedule in production

Get alerted the moment this cron job fails, is late, or doesn't run. BetterStack tracks execution, duration, and output — no infrastructure required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

EventBridge Rule
cron(0 */2 * * ? *)

Systemd Timer

OnCalendar*-*-* 00/2:00:00

my-task.timer
[Unit]
Description=Timer for cron expression: 0 */2 * * *

[Timer]
OnCalendar=*-*-* 00/2:00:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How do I prevent overlapping runs if a job takes longer than two hours?

Implement a locking mechanism. In Kubernetes, set `concurrencyPolicy: Forbid`. On Linux servers, wrap your script in a utility like `flock` or utilize distributed lock managers like Redis (Redlock) or Consul to ensure only one instance runs at any given time.

What is the best way to handle Daylight Saving Time changes with this schedule?

Configure your system clock, cron daemon, or container runtime to use Coordinated Universal Time (UTC). Operating on UTC guarantees that the job executes consistently every 120 minutes without skipping or running twice during seasonal clock adjustments.

How does 0 */2 * * * differ from matching every minute like */120 * * * *?

Standard cron engines do not support step intervals larger than 59 in the minutes field. Therefore, `*/120` is invalid. The expression `0 */2 * * *` specifies execution specifically at minute zero of every second hour (e.g., 12:00, 2:00, 4:00).

How can I spread the load if multiple cron tasks run at the same time?

Avoid scheduling all tasks at minute `0`. Shift the execution minute to an arbitrary value (for example, `17 */2 * * *` or `43 */2 * * *`). This distributes network, memory, and CPU utilization across your server infrastructure.

How should I monitor this cron job to ensure it runs successfully?

Use a passive monitoring tool or 'dead man's snitch' that expects an HTTP ping every two hours. Configure a grace period of 2.5 hours. If the service fails to ping within that window, trigger an alert via PagerDuty, Slack, or email.

* Explore

Related expressions you might need

Last verified:

Was this helpful?