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
*
How it works

Next 5 Runs

  • in 11h 19m
  • in 23h 19m
  • in 1d 11h
  • in 1d 23h
  • in 2d 11h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# System crontab installation instructions:
# 1. Run 'crontab -e' to edit the user's crontab file
# 2. Add the following line to execute twice daily at 8 AM and 8 PM
# 0 8,20 * * * /usr/local/bin/run-sync-job.sh >> /var/log/sync-job.log 2>&1

set -euo pipefail

LOCKFILE="/var/tmp/sync-job.lock"

# Prevent overlapping executions using a file lock
exec 9>>"$LOCKFILE"
if ! flock -n 9; then
    echo "[$(date)] Job is already running. Exiting to prevent overlap." >&2
    exit 1
fi

echo "[$(date)] Starting twice-daily synchronization task..."
# Place your production logic here (e.g., database synchronization, API polling)
/usr/bin/curl -f -s https://api.example.com/sync || {
    echo "[$(date)] Error: Sync API call failed" >&2
    exit 1
}
echo "[$(date)] Task completed successfully."
Setup notes

Place the script in /usr/local/bin/run-sync-job.sh, make it executable with chmod +x, and add the cron definition line to your system crontab using crontab -e.

Last verified:

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

Last verified:

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

Last verified:

Was this helpful?