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

Next 5 Runs

  • in 3h 22m
  • in 11h 22m
  • in 19h 22m
  • in 1d 3h
  • in 1d 11h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Production-ready Bash wrapper for 8-hour cron job
set -euo pipefail

LOCKFILE="/var/lock/eight_hour_backup.lock"
exec 9>"$LOCKFILE"

# Acquire exclusive non-blocking lock to prevent overlapping runs
if ! flock -n 9; then
    echo "Error: Another instance of this job is already running." >&2
    exit 1
fi

echo "[$(date -u)] Starting 8-hour system maintenance task..."
# Real task execution
/usr/local/bin/backup-db.sh --target s3://my-bucket/backups

echo "[$(date -u)] Task completed successfully."
Setup notes

Save this script to /usr/local/bin/run-backup.sh, make it executable with chmod +x, and add '0 */8 * * * /usr/local/bin/run-backup.sh' to your crontab.

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

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

Last verified:

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

Last verified:

Was this helpful?