Run Every 8 Hours Cron Schedule | CronBase

cron expression Standard
$ 0 */8 * * *

Every eight hours at the very beginning of the hour.

The `0 */8 * * *` cron expression schedules a task to run exactly every eight hours, specifically at midnight, eight in the morning, and four in the afternoon. This three-times-daily interval is commonly used for intermediate database backups, log rotation, system health checks, and periodic API data synchronization.

Minute
0
Hour
*/8
Day of Month
*
Month
*
Day of Week
*

Next 5 Runs

  • in 6h 2m
  • in 14h 2m
  • in 22h 2m
  • in 1d 6h
  • in 1d 14h

* Tools

Code & Implementations

nodejs
// Node.js 8-hour cron scheduler using 'node-cron'
const cron = require('node-cron');
const { exec } = require('child_process');

// Schedule: 0 */8 * * * (Every 8 hours at minute 0)
cron.schedule('0 */8 * * *', () => {
    console.log(`[${new Date().toISOString()}] Initiating scheduled data sync...`);
    
    exec('/usr/bin/node /app/sync.js', (error, stdout, stderr) => {
        if (error) {
            console.error(`[Error] Execution failed: ${error.message}`);
            return;
        }
        if (stderr) {
            console.warn(`[Warning] Stderr output: ${stderr}`);
        }
        console.log(`[Success] Sync output: ${stdout}`);
    });
}, {
    scheduled: true,
    timezone: "UTC"
});
Setup notes

Install node-cron using 'npm install node-cron' and run this script as a daemon process using PM2 or systemd.

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 */8 * * ? *)

Systemd Timer

OnCalendar*-*-* 00/8:00:00

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

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

[Install]
WantedBy=timers.target

Frequently Asked Questions

How do I offset this job to avoid top-of-the-hour traffic spikes?

You can change the first field (minutes) to a specific offset, such as `15 */8 * * *` to run at 15 minutes past the hour, or `42 */8 * * *` to run at 42 minutes past. This distributes load and prevents resource contention.

Will this job run exactly three times a day during DST transitions?

If your cron daemon runs on local server time in a region with DST, the job may run twice or four times on transition days, with intervals of 7 or 9 hours. To prevent this, always configure your cron daemon or scheduler to evaluate in UTC.

What happens if a run takes longer than 8 hours to complete?

Standard cron will launch a new process even if the previous one is still running. This can lead to race conditions and memory exhaustion. Use locking mechanisms like `flock` in Bash, Redis locks, or Kubernetes' `concurrencyPolicy: Forbid` to prevent overlaps.

How can I test this schedule locally without waiting 8 hours?

For testing purposes, temporarily modify the expression to `*/5 * * * *` (every 5 minutes) or run the target script/command directly outside of the cron daemon to verify its functionality and output handling.

Is there a difference between `0 */8 * * *` and `0 0,8,16 * * *`?

No, they are functionally identical in standard cron. Both schedule executions at 00:00, 08:00, and 16:00. The list syntax `0,8,16` is sometimes preferred for explicit clarity, while the step syntax `*/8` is more concise.

* Explore

Related expressions you might need

Was this helpful?

Last verified: