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

Next 5 Runs

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

* Tools

Code & Implementations

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

// Schedule task to run every Sunday at 3:00 AM
cron.schedule('0 3 * * 0', () => {
  console.log(`[${new Date().toISOString()}] Initiating weekly cleanup job...`);
  
  exec('/usr/local/bin/weekly-cleanup.sh', (error, stdout, stderr) => {
    if (error) {
      console.error(`[ERROR] Weekly cleanup failed: ${error.message}`);
      return;
    }
    if (stderr) {
      console.warn(`[WARNING] Standard error output: ${stderr}`);
    }
    console.log(`[SUCCESS] Cleanup output:\n${stdout}`);
  });
}, {
  scheduled: true,
  timezone: "UTC"
});
Setup notes

Install 'node-cron' via npm. Run this process in the background using a process manager like PM2 to guarantee continuous execution and automatic restarts.

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

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

Was this helpful?

Last verified: