Twice-Daily 8 AM and 8 PM Cron Schedule | CronBase

cron expression Standard
$ 0 8,20 * * *

Twice daily, once in the morning and once in the evening.

The `0 8,20 * * *` cron expression schedules a task to run twice every day, specifically at 8:00 AM and 8:00 PM. This twelve-hour interval is highly effective for synchronizing databases, generating morning and evening reports, or performing routine system maintenance during shift transitions without disrupting standard business operations.

Minute
0
Hour
8,20
Day of Month
*
Month
*
Day of Week
*

Next 5 Runs

  • in 10h 1m
  • in 22h 1m
  • in 1d 10h
  • in 1d 22h
  • in 2d 10h

* Tools

Code & Implementations

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

// Schedule task to run twice daily at 8:00 AM and 8:00 PM
const task = cron.schedule('0 8,20 * * *', () => {
  console.log(`[${new Date().toISOString()}] Initiating twice-daily reporting pipeline...`);
  
  try {
    // Execute your business logic or external shell scripts here
    exec('/usr/local/bin/generate-report.sh', (error, stdout, stderr) => {
      if (error) {
        console.error(`Execution error: ${error.message}`);
        return;
      }
      if (stderr) {
        console.warn(`Warnings: ${stderr}`);
      }
      console.log(`Pipeline output: ${stdout.trim()}`);
    });
  } catch (err) {
    console.error('Unexpected scheduler execution error:', err);
  }
}, {
  scheduled: true,
  timezone: "UTC"
});

console.log('Twice-daily scheduler initialized for 08:00 and 20:00 UTC.');
Setup notes

Install the standard dependency using npm install node-cron and run this daemon process using a process manager like PM2 to guarantee uptime.

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,20 * * ? *)

Systemd Timer

OnCalendar*-*-* 08,20:00:00

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

[Timer]
OnCalendar=*-*-* 08,20:00:00
Persistent=true

[Install]
WantedBy=timers.target

Frequently Asked Questions

How do I handle daylight saving time shifts for this twice-daily schedule?

If your server runs on local time, DST transitions in spring and autumn might cause the 8 AM or 8 PM runs to execute twice or be skipped entirely. To prevent this, standardise your system clock to UTC, which does not observe DST, and adjust your cron schedule offset manually if business requirements dictate local time alignment.

What happens if the 8 AM execution is still running when the 8 PM execution starts?

If a run exceeds 12 hours, standard cron will spawn a concurrent process, potentially causing database lock contention or race conditions. Implement a locking mechanism such as `flock` in Bash, a distributed lock manager like Redis (Redlock) in your application code, or set `concurrencyPolicy: Forbid` in Kubernetes.

How can I add a randomized delay to prevent simultaneous resource spikes?

To avoid overloading downstream APIs or databases at exactly 8:00, introduce a random sleep or jitter. In Bash, you can prepend `sleep $((RANDOM % 300))` to delay execution by up to 5 minutes, or handle this programmatically within your application code before executing the main business logic.

Can I run this schedule only on weekdays instead of every day?

Yes, you can modify the fifth field of the cron expression. Changing the expression to `0 8,20 * * 1-5` will restrict the twice-daily execution to Monday through Friday, skipping weekends entirely.

How should I monitor and alert on failures for this specific twice-daily cadence?

Configure dead man's snitches or heartbeat monitoring (like Healthchecks.io or Prometheus alertmanager) with an expected check-in interval of 12 hours. If the system fails to check in within a defined grace period (e.g., 13 hours), trigger high-priority paging alerts to your on-call engineering team.

* Explore

Related expressions you might need

Was this helpful?

Last verified: