Run Jobs Every Twelve Hours at 6 AM and 6 PM | CronBase

cron expression Standard
$ 0 6,18 * * *

Twice daily at six in the morning and six in the evening.

The `0 6,18 * * *` cron expression schedules a task to execute twice every day at exactly 6:00 AM and 6:00 PM (18:00) in the system's local timezone. This twelve-hour interval is commonly used for morning readiness checks, shift-change reporting, and twice-daily database backups.

Minute
0
Hour
6,18
Day of Month
*
Month
*
Day of Week
*

Next 5 Runs

  • in 8h 0m
  • in 20h 0m
  • in 1d 8h
  • in 1d 20h
  • in 2d 8h

* Tools

Code & Implementations

nodejs
const cron = require('node-cron');
const { exec } = require('child_process');

// Schedule task to run at 06:00 and 18:00 daily
cron.schedule('0 6,18 * * *', () => {
  console.log(`[${new Date().toISOString()}] Starting twice-daily synchronization job...`);
  exec('/opt/scripts/sync.sh', (error, stdout, stderr) => {
    if (error) {
      console.error(`Error executing sync script: ${error.message}`);
      return;
    }
    if (stderr) {
      console.warn(`Sync warning: ${stderr}`);
    }
    console.log(`Sync completed successfully: ${stdout}`);
  });
}, {
  scheduled: true,
  timezone: 'UTC'
});
Setup notes

Install node-cron via npm, save the script as scheduler.js, and run it using a 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 6,18 * * ? *)

Systemd Timer

OnCalendar*-*-* 06,18:00:00

my-task.timer
[Unit]
Description=Timer for cron expression: 0 6,18 * * *

[Timer]
OnCalendar=*-*-* 06,18:00:00
Persistent=true

[Install]
WantedBy=timers.target

Frequently Asked Questions

How does Daylight Saving Time (DST) affect this twice-daily schedule?

During DST transitions, the local time jumps. In spring, if the transition occurs at 2 AM, your 6 AM and 6 PM jobs run normally but the interval between them might temporarily be 11 or 13 hours. Ensure your cron daemon (like systemd-cron or cronie) is configured to use UTC to maintain a strict 12-hour interval.

Can I stagger execution to avoid database connection spikes at 06:00 and 18:00?

Yes, you can introduce a random start delay (jitter) within your execution script. For example, in Bash, use `sleep $((RANDOM % 300))` to delay the start by up to 5 minutes, spreading the resource load across your cluster.

How do I run this schedule on AWS ECS or AWS EventBridge?

In AWS EventBridge, standard cron syntax is supported but requires 6 fields. You must convert `0 6,18 * * *` to `cron(0 6,18 * * ? *)` or `cron(0 6,18 ? * * *)` depending on the target resource, specifying UTC explicitly.

What is the best way to monitor if both executions succeeded?

Implement dead man's snitches or heartbeat monitoring (e.g., Healthchecks.io). Configure the monitoring service to expect a ping twice daily with a 12-hour period and a grace period of 15 minutes to account for execution delays.

How can I change this to run every 12 hours starting from midnight instead?

If you want to shift the 12-hour interval to start at midnight and noon, modify the expression to `0 0,12 * * *`. This keeps the same frequency but aligns with traditional calendar day splits.

* Explore

Related expressions you might need

Was this helpful?

Last verified: