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

Next 5 Runs

  • in 2d 16h
  • in 9d 16h
  • in 16d 16h
  • in 23d 16h
  • in 30d 16h

* Tools

Code & Implementations

nodejs
const cron = require('node-cron');
const { exec } = require('child_process');

// Schedule task to run at 2:00 AM every Monday
cron.schedule('0 2 * * 1', () => {
    console.log(`[${new Date().toISOString()}] Initiating weekly cleanup...`);
    
    exec('/usr/local/bin/cleanup-script.sh', (error, stdout, stderr) => {
        if (error) {
            console.error(`Execution error: ${error.message}`);
            return;
        }
        if (stderr) {
            console.warn(`Execution warning: ${stderr}`);
        }
        console.log(`Execution success: ${stdout}`);
    });
}, {
    scheduled: true,
    timezone: "UTC"
});
Setup notes

Install node-cron using 'npm install node-cron' and run this script using node. Ensure your process manager (like PM2) keeps the process alive.

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

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

Was this helpful?

Last verified: