Run Weekly Backups on Mondays at 2 AM | CronBase

cron expression Standard
$ 0 2 * * 1

Every Monday morning at two o'clock.

This cron expression schedules a task to run once a week on Mondays at exactly 2:00 AM. It is widely used in production environments for executing resource-intensive weekly maintenance tasks, such as database vacuuming, log archiving, SSL certificate renewals, and system backups, during low-traffic periods.

Minute
0
Hour
2
Day of Month
*
Month
*
Day of Week
1
How it works

Next 5 Runs

  • in 1d 5h
  • in 8d 5h
  • in 15d 5h
  • in 22d 5h
  • in 29d 5h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
set -euo pipefail

# Define lock file to prevent concurrent executions
LOCKFILE="/var/lock/weekly-maintenance.lock"

# Execute weekly task with flock to ensure exclusive execution
exec 9>"$LOCKFILE"
if flock -n 9; then
    echo "[$(date -u)] Starting weekly maintenance task..."
    # Insert production commands here
    # Example: /usr/local/bin/backup-db.sh
    echo "[$(date -u)] Task completed successfully."
else
    echo "[$(date -u)] Error: Task is already running!"
    exit 1
fi
Setup notes

Add the entry to your system crontab by running 'crontab -e' and appending: 0 2 * * 1 /usr/local/bin/weekly-maintenance.sh >> /var/log/cron-weekly.log 2>&1

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

Systemd Timer

OnCalendarMon *-*-* 02:00:00

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

[Timer]
OnCalendar=Mon *-*-* 02:00:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How does Daylight Saving Time (DST) affect a job scheduled at 2:00 AM?

During DST transitions, 2:00 AM might occur twice (autumn) or not at all (spring). To prevent skipped or duplicate executions, run your system clock and cron daemon in UTC, which does not observe DST.

What happens if the server is powered off at Monday 2:00 AM?

Standard cron will not run missed jobs retroactively when the server boots back up. If you need guaranteed execution of missed tasks, consider using anacron or a systemd timer with Persistent=true.

Is Monday at 2:00 AM a safe time to run heavy database migrations?

While traffic is generally low, running migrations right before the business week starts is risky. If the migration fails or locks tables, it may disrupt Monday morning business. Consider scheduling migrations for Saturday night instead.

How can I prevent multiple instances of this weekly job from overlapping?

Use a locking utility like flock in Bash, or a distributed lock manager (like Redis/Redlock) if running in a clustered environment, to ensure only one instance of the job executes at a time.

How do I test this cron expression locally before deploying it?

You can use online parser tools to verify the schedule, or simulate it locally by setting your system time to Sunday 1:59 AM in a containerized environment to watch the execution trigger at 2:00 AM.

* Explore

Related expressions you might need

Last verified:

Was this helpful?