Run Hourly Tasks During Business Hours | CronBase

cron expression Standard
$ 0 9-17 * * 1-5

Hourly on the hour during standard business hours from Monday through Friday.

The `0 9-17 * * 1-5` cron expression triggers a task at the top of every hour from 9:00 AM to 5:00 PM, Monday through Friday. It is designed to automate operational processes, system health checks, and data synchronizations exclusively during standard corporate business hours.

Minute
0
Hour
9-17
Day of Month
*
Month
*
Day of Week
1-5

Next 5 Runs

  • in 1m 2s
  • in 1h 1m
  • in 2h 1m
  • in 3h 1m
  • in 4h 1m

* Tools

Code & Implementations

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

// Schedule to run hourly from 9 AM to 5 PM, Monday to Friday
// Cron syntax: 0 9-17 * * 1-5
cron.schedule('0 9-17 * * 1-5', async () => {
    console.log(`[${new Date().toISOString()}] Initiating business hours task...`);
    try {
        await runTask();
        console.log(`[${new Date().toISOString()}] Task completed successfully.`);
    } catch (error) {
        console.error(`[${new Date().toISOString()}] Task failed:`, error);
    }
}, {
    scheduled: true,
    timezone: "America/New_York" // Explicitly define business timezone
});

async function runTask() {
    return new Promise((resolve) => {
        // Implement business logic here
        resolve();
    });
}
Setup notes

Install node-cron via npm, copy this implementation into your application bootstrap file, and ensure your system timezone is correctly configured or explicitly declared.

Partner UptimeRobot

Keep this cron job monitored 24/7

UptimeRobot alerts you the moment a scheduled job stops responding. Free plan monitors up to 50 endpoints — no credit card required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

EventBridge Rule
cron(0 9-17 ? * 1-5 *)

Systemd Timer

OnCalendarMon..Fri *-*-* 09..17:00:00

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

[Timer]
OnCalendar=Mon..Fri *-*-* 09..17:00:00
Persistent=true

[Install]
WantedBy=timers.target

Frequently Asked Questions

How does timezone configuration affect this business-hours schedule?

By default, standard cron operates on the host system's timezone (often UTC). If your business operates in a different timezone, you must adjust the hour range in the expression or configure your cron daemon (such as systemd-cron or Kubernetes cronjob timezone) to match your local business hours.

What happens if a task runs longer than one hour?

If a task takes longer than 60 minutes, the next scheduled instance will start while the previous one is still running. To prevent this overlap, implement locking mechanisms like flock in Bash, or use singleton execution patterns in your application code.

Does this expression run at exactly 5:00 PM?

Yes, the range '9-17' is inclusive. The task will execute at 9:00 AM, hourly throughout the day, with the final execution of the day occurring at exactly 5:00 PM (17:00). It will not run at 5:01 PM or later.

How can I add a randomized delay to prevent server spikes?

You can introduce a random sleep command at the start of your execution. In Bash, using `sleep $((RANDOM % 60))` delays the start by up to one minute, smoothing out resource consumption across multiple concurrent jobs.

Why is my Kubernetes CronJob not triggering on this schedule?

Ensure your Kubernetes cluster controller-manager is configured with the correct timezone, or use the `spec.timeZone` field (available in Kubernetes 1.27+) to explicitly define the timezone for your CronJob manifest.

* Explore

Related expressions you might need

Was this helpful?

Last verified: