Run Every Two Hours on Weekdays | CronBase

cron expression Standard
$ 0 */2 * * 1-5

Every two hours on weekdays from Monday through Friday.

This cron expression schedules a task to run at the start of every second hour, specifically on the hour mark, from Monday through Friday. It does not execute on weekends, making it ideal for processing business-day data streams, synchronizing enterprise systems, and performing regular weekday maintenance tasks.

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

Next 5 Runs

  • in 1d 3h
  • in 1d 5h
  • in 1d 7h
  • in 1d 9h
  • in 1d 11h

* Tools

Code & Implementations

Bash
#!/bin/bash
# Lock file to prevent overlapping executions
LOCKFILE="/var/run/weekday_sync.lock"
exec 200>"$LOCKFILE"
if ! flock -n 200; then
  echo "Error: Another instance of the job is already running." >&2
  exit 1
fi
echo "Starting weekday sync task..."
# Real-world task execution
curl -f -s https://api.example.com/sync || { echo "Sync failed" >&2; exit 1; }
echo "Task completed successfully."
Setup notes

Save this script to /usr/local/bin/weekday-sync.sh, make it executable with chmod +x, and add it 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 ? * 1-5 *)

Systemd Timer

OnCalendarMon..Fri *-*-* 00/2:00:00

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How does this schedule handle Daylight Saving Time (DST) transitions?

Standard cron relies on system time. During DST changes, the 2:00 AM run might execute twice or be skipped entirely. To prevent issues, configure your servers to run on UTC or use an application-level scheduler that handles DST offsets seamlessly.

What happens if a job takes longer than two hours to complete?

If a job exceeds the two-hour window, standard cron will start a new instance alongside the running one. This can cause race conditions or resource exhaustion. Use a locking mechanism like flock in Bash or distributed locks in your application code to prevent overlapping runs.

Does this expression run on weekends at all?

No, the day-of-week field is restricted to 1-5 (Monday through Friday). The schedule stops running after the last execution on Friday (usually 10 PM depending on alignment) and resumes on Monday at midnight (00:00).

How can I test this cron schedule locally before deploying to production?

You can use online parsers to verify the execution times or simulate the schedule using a tool like croniter in Python or robfig/cron dry-runs in Go. Additionally, check your local system logs after running a short-interval test.

Why is my task running at odd hours instead of even hours?

The step syntax */2 starts counting from 0. Therefore, executions occur at 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, and 22 hours. If your system clock is misconfigured or set to a different timezone, these hours might not align with your local business day.

* Explore

Related expressions you might need

Last verified:

Was this helpful?