Run Daily Backups and Syncs at 10 PM | CronBase

cron expression Standard
$ 0 22 * * *

Every day in the evening at ten PM

The `0 22 * * *` cron expression triggers a scheduled task every day at exactly 10:00 PM (22:00) in the system's local timezone. It is widely used in production environments for executing nightly database backups, processing daily batch transactions, rotating system logs, and initiating off-peak synchronization tasks before the midnight rollover.

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

Next 5 Runs

  • in 12h 1m
  • in 1d 12h
  • in 2d 12h
  • in 3d 12h
  • in 4d 12h

* Tools

Code & Implementations

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

// Schedule task to run daily at 22:00 (10:00 PM)
cron.schedule('0 22 * * *', () => {
  console.log(`[${new Date().toISOString()}] Starting nightly database backup...`);
  
  exec('/usr/local/bin/backup-db.sh', (error, stdout, stderr) => {
    if (error) {
      console.error(`[ERROR] Backup failed: ${error.message}`);
      return;
    }
    if (stderr) {
      console.warn(`[WARN] Backup stderr: ${stderr}`);
    }
    console.log(`[SUCCESS] Backup completed. Output: ${stdout}`);
  });
}, {
  scheduled: true,
  timezone: "Etc/UTC"
});
Setup notes

Install the dependency using npm install node-cron. Run this background process using a process manager like PM2 to guarantee constant uptime.

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

Systemd Timer

OnCalendar*-*-* 22:00:00

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

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

[Install]
WantedBy=timers.target

Frequently Asked Questions

How does Daylight Saving Time (DST) affect a 10 PM daily cron job?

Depending on your OS timezone database, DST shifts can cause the job to run an hour early or late relative to UTC, or potentially skip/double-execute if transitioning during that hour. Running your system clock on UTC is the industry standard to ensure consistent 24-hour intervals.

Can I run this job only on weekdays instead of every day?

Yes, you can modify the fifth field (day-of-week) to restrict execution. Changing the expression to `0 22 * * 1-5` will run the task at 10 PM Monday through Friday, skipping Saturday and Sunday.

What happens if the server is offline at 10 PM when the job is scheduled?

Standard cron does not catch up on missed executions. If your server is offline at 22:00, the job will not run until 10 PM the following day. For critical tasks, use utilities like anacron or implement a startup check script.

How do I prevent multiple instances of this 10 PM job from overlapping?

Use a locking mechanism like `flock` in Linux, or a distributed lock manager like Redis (Redlock) if running across multiple nodes. This ensures that if the previous day's task is still running, the new instance terminates safely.

Why is my 10 PM cron job running at 5 PM local time?

This discrepancy occurs because your server's system clock is configured to UTC (or a different timezone) rather than your local timezone. Check your system time using the `date` command and adjust either the server timezone or the cron hour accordingly.

* Explore

Related expressions you might need

Was this helpful?

Last verified: