Run Daily 3 AM Database Backups | CronBase

cron expression Standard
$ 0 3 * * *

Every single day in the middle of the night at exactly three o'clock in the morning.

The `0 3 * * *` cron expression schedules a task to run daily at exactly 3:00 AM. This off-peak timing is ideal for resource-intensive operations like database backups, log rotation, data warehousing ETL syncs, and system updates, ensuring minimal performance impact on active daytime users.

Minute
0
Hour
3
Day of Month
*
Month
*
Day of Week
*
How it works

Next 5 Runs

  • in 6h 21m
  • in 1d 6h
  • in 2d 6h
  • in 3d 6h
  • in 4d 6h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Crontab entry: 0 3 * * * /usr/local/bin/daily_backup.sh
set -euo pipefail

LOCKFILE="/var/tmp/daily_backup.lock"

# Prevent concurrent execution of the daily 3 AM backup
exec 9>"$LOCKFILE"
if ! flock -n 9; then
    echo "Error: Another backup process is already running." >&2
    exit 1
fi

echo "Starting daily maintenance at $(date)"
# Perform backup operations here
/usr/local/bin/backup_db.sh --output /mnt/backups/daily/

echo "Daily maintenance completed successfully."
Setup notes

Place this script in /usr/local/bin/daily_backup.sh, make it executable with chmod +x, and add 0 3 * * * /usr/local/bin/daily_backup.sh to your system crontab.

Last verified:

Partner UptimeRobot

Keep this cron job monitored 24/7

UptimeRobot alerts you the moment a scheduled job stops responding. Free plan monitors up to 50 endpoints — no credit card required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

EventBridge Rule
cron(0 3 * * ? *)

Systemd Timer

OnCalendar*-*-* 03:00:00

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

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How does Daylight Saving Time affect a 3:00 AM cron schedule?

Depending on your local timezone settings, the transition into Daylight Saving Time can cause the 3:00 AM job to run twice or skip entirely. Running your servers on UTC is the industry best practice to prevent this issue.

What happens if a previous day's 3:00 AM run is still executing when the next one starts?

Standard cron daemons will launch a concurrent process, which can lead to database deadlocks or resource starvation. You should implement locking mechanisms like 'flock' in Bash or distributed locks in application code to prevent overlapping.

How can I stagger multiple jobs scheduled at 3:00 AM to prevent resource spikes?

Introduce a randomized delay or sleep interval at the start of your scripts. For example, prepending 'sleep $((RANDOM % 300))' in a Bash task staggers execution across a five-minute window.

How should I monitor this off-hours job to ensure it actually ran?

Do not rely solely on push notifications. Use a 'dead-man's switch' monitoring service (like Healthchecks.io or Opsgenie) that alerts you if a ping is not received by 3:15 AM.

Can I restrict this daily 3:00 AM run to only execute on weekdays?

Yes, you can modify the expression to '0 3 * * 1-5' to target Monday through Friday, or '0 3 * * 1,2,3,4,5' depending on your specific cron dialect's syntax support.

* Explore

Related expressions you might need

Last verified:

Was this helpful?