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

Next 5 Runs

  • in 15s
  • in 2h 0m
  • in 4h 0m
  • in 6h 0m
  • in 8h 0m

* Tools

Code & Implementations

nodejs
const cron = require('node-cron');
const axios = require('axios');

// Schedule task for every 2 hours on weekdays
cron.schedule('0 */2 * * 1-5', async () => {
  console.log('Starting scheduled weekday data synchronization...');
  try {
    const response = await axios.post('https://api.example.com/v1/sync');
    console.log(`Sync completed with status: ${response.status}`);
  } catch (error) {
    console.error('Execution failed during weekday sync:', error.message);
  }
}, {
  scheduled: true,
  timezone: "UTC"
});
Setup notes

Install node-cron and axios using npm, then run this script using node in a daemonized process manager like PM2 to ensure continuous execution.

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

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

Was this helpful?

Last verified: