Schedule Weekly Sunday Maintenance at 3 AM | CronBase

cron expression Standard
$ 0 3 * * 0

Every Sunday morning at three o'clock

This cron expression schedules a task to run every Sunday morning at exactly 3:00 AM. It is a highly popular cadence for executing heavy weekly maintenance, database optimization, disk defragmentation, log rotation, and deep analytical reports during off-peak hours when user traffic and system load are at their absolute lowest.

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

Next 5 Runs

  • in 6h 34m
  • in 7d 6h
  • in 14d 6h
  • in 21d 6h
  • in 28d 6h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash

# Ensure the script exits on any error
set -euo pipefail

# Log file configuration
LOG_FILE="/var/log/weekly_maintenance.log"

# Main execution function
run_maintenance() {
    echo "[$(date -u)] Starting weekly maintenance task..." >> "$LOG_FILE"
    # Add your production backup or cleanup command here
    # e.g., pg_dumpall -U postgres | gzip > /backups/db_$(date +%F).sql.gz
    echo "[$(date -u)] Maintenance completed successfully." >> "$LOG_FILE"
}

# Execute with error logging
if ! run_maintenance; then
    echo "[$(date -u)] CRITICAL: Weekly maintenance failed!" >&2
    exit 1
fi
Setup notes

Add the script to your system cron by running 'crontab -e' and adding the line: '0 3 * * 0 /path/to/your/script.sh'. Ensure the script has executable permissions using 'chmod +x'.

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

Systemd Timer

OnCalendarSun *-*-* 03:00:00

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How does Daylight Saving Time affect a job scheduled at 3 AM on Sunday?

Depending on your local timezone rules, the 3:00 AM transition during Spring Forward might cause the cron daemon to skip execution or run it late, while Autumn Back could trigger it twice if the daemon doesn't handle offsets correctly. Running your system clock in UTC entirely eliminates this unpredictability.

Can I run multiple heavy maintenance scripts simultaneously at this hour?

It is highly discouraged to run multiple resource-intensive tasks at exactly 3:00 AM. Instead, chain your scripts sequentially using a wrapper script or orchestrator, or space them out (e.g., one at 3:00 AM, another at 4:30 AM) to prevent CPU starvation and disk I/O bottlenecks.

What happens if the server is offline when 3:00 AM Sunday passes?

Standard cron daemons will not run missed jobs once the server boots back up. If missed executions are unacceptable for your workflow, you should utilize anacron (for non-server systems) or a modern orchestration tool like Kubernetes CronJobs with a concurrency policy and starting deadline.

Is Sunday at 0 or 7 in standard cron configurations?

In standard POSIX and Vixie cron implementations, both 0 and 7 represent Sunday. Using 0 is universally supported across almost all cron engines, making it the safest choice for cross-platform compatibility and Infrastructure-as-Code definitions.

How should I handle alerting for a job that only runs once a week?

Passive monitoring (waiting for a failure alert) is risky for weekly jobs because a silent failure might go unnoticed for days. Implement 'dead man's snitch' heartbeat monitoring, where your job pings an external monitoring service upon successful completion, alerting you if no ping is received by 3:15 AM Sunday.

* Explore

Related expressions you might need

Last verified:

Was this helpful?