Run Weekly Saturday Midnight Backups | CronBase

cron expression Standard
$ 0 0 * * 6

Every Saturday at midnight

The `0 0 * * 6` cron expression schedules a task to run once a week at exactly midnight every Saturday. It is commonly used in production environments for heavy weekly maintenance jobs, database optimization, full system backups, and generating weekly analytical reports during low-traffic weekend hours.

Minute
0
Hour
0
Day of Month
*
Month
*
Day of Week
6

Next 5 Runs

  • in 14h 0m
  • in 7d 14h
  • in 14d 14h
  • in 21d 14h
  • in 28d 14h

* Tools

Code & Implementations

nodejs
const cron = require('cron');
const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  transports: [new winston.transports.Console()]
});

// Cron pattern for every Saturday at midnight
const job = new cron.CronJob('0 0 * * 6', async () => {
  logger.info('Starting scheduled weekly database maintenance...');
  try {
    // Perform database optimization and cleanup
    await performWeeklyMaintenance();
    logger.info('Weekly maintenance completed successfully.');
  } catch (error) {
    logger.error('Failed to execute weekly maintenance:', error);
  }
}, null, true, 'UTC');

async function performWeeklyMaintenance() {
  // Production-ready maintenance logic here
  return Promise.resolve();
}

job.start();
Setup notes

Install the cron and winston packages using npm install cron winston. Run this script as a daemon utilizing a process manager like PM2 to guarantee continuous scheduling.

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

Systemd Timer

OnCalendarSat *-*-* 00:00:00

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

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

[Install]
WantedBy=timers.target

Frequently Asked Questions

How does Daylight Saving Time (DST) affect the Saturday midnight execution?

Depending on your system's timezone, a DST transition can cause the job to run twice or not at all if it occurs on that night. To prevent this, configure your cron daemon or scheduler to run on UTC.

What happens if a previous week's execution is still running when the next Saturday comes?

For standard cron, the job will spawn concurrently, potentially causing race conditions. Use locking mechanisms like `flock` in Bash, or set `concurrencyPolicy: Forbid` in Kubernetes to prevent overlapping.

Can I run this job on Friday night instead of Saturday night?

Yes, you can change the day-of-week field from `6` (Saturday) to `5` (Friday). The expression would then be `0 0 * * 5`, executing at midnight as Friday transitions to Saturday.

How should I monitor a weekly job to ensure it actually ran?

Since weekly jobs run infrequently, passive logging is insufficient. Use a push-based monitoring system ("Dead Man's Snitch") where the job pings an external service on completion; if no ping is received by 00:15 Saturday, an alert is raised.

Is there a way to run the job at 2:00 AM on Saturday instead of midnight?

Yes, modifying the hour field from `0` to `2` changes the execution time. The expression `0 2 * * 6` is often preferred to avoid resource contention with other midnight-scheduled tasks.

* Explore

Related expressions you might need

Was this helpful?

Last verified: