Schedule Tasks Every Six Hours | CronBase

cron expression Standard
$ 0 0,6,12,18 * * *

Every six hours at midnight, morning, noon, and evening.

This standard cron expression schedules a task to run four times a day, precisely at the start of the hour every six hours. It executes at midnight, morning, midday, and evening. This interval is commonly used for secondary backups, synchronizing external APIs, and processing data pipelines.

Minute
0
Hour
0,6,12,18
Day of Month
*
Month
*
Day of Week
*
How it works

Next 5 Runs

  • in 3h 18m
  • in 9h 18m
  • in 15h 18m
  • in 21h 18m
  • in 1d 3h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Production Bash script for 6-hour cron task
# Uses flock to prevent overlapping runs
set -euo pipefail
LOCKFILE="/var/lock/six_hour_job.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
  echo "Error: Another instance of the job is already running." >&2
  exit 1
fi
echo "[$(date -u)] Starting six-hour maintenance task..."
# Add your actual production payload here
# Example: /usr/local/bin/backup-db.sh
echo "[$(date -u)] Maintenance task completed successfully."
Setup notes

Place this script in /usr/local/bin/six-hour-job.sh, make it executable, and add 0 0,6,12,18 * * * /usr/local/bin/six-hour-job.sh to your system 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 0,6,12,18 * * ? *)

Systemd Timer

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

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How do I prevent overlapping executions if a job takes longer than six hours?

You should implement a distributed locking mechanism using Redis or database-backed locks. In Bash, you can use the `flock` utility to prevent a new instance from starting if the previous execution is still running.

What happens to this schedule during Daylight Saving Time (DST) changes?

If your system timezone is set to a local time that observes DST, the 2:00 AM transition can cause the 6:00 AM execution to run early, late, or be skipped. Running your system clock and cron daemon in UTC completely eliminates this risk.

Can I stagger this schedule to avoid peak hour traffic?

Yes, you can shift the execution to a different minute or hour offset. For example, changing the expression to `15 1,7,13,19 * * *` shifts the execution by one hour and fifteen minutes, avoiding resource contention on the hour.

How can I monitor if a six-hour job failed to run?

Implement dead man's snitches or heartbeat monitoring (such as Healthchecks.io or Opsgenie). These services alert your team if they do not receive a ping within a specified window (e.g., six hours and ten minutes).

Is this schedule suitable for high-frequency database backups?

It is ideal for staging or non-critical production databases. However, for critical production databases with high transaction volumes, a six-hour interval may risk losing too much data; a combination of daily full backups and hourly transaction log shipping is preferred.

* Explore

Related expressions you might need

Last verified:

Was this helpful?