Run Daily Late-Night Maintenance at 11:45 PM | CronBase

cron expression Standard
$ 45 23 * * *

Every day late in the evening, exactly fifteen minutes before midnight.

The `45 23 * * *` cron expression schedules a task to run every day at exactly 11:45 PM. This late-night timing is ideal for executing end-of-day database backups, running daily log rotations, compiling daily activity reports, and performing system cleanup tasks right before the calendar day transitions to midnight.

Minute
45
Hour
23
Day of Month
*
Month
*
Day of Week
*
How it works

Next 5 Runs

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

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Production-ready daily late-night backup script designed for 23:45 execution.
# Uses flock to prevent concurrent execution if a previous run hangs.
set -euo pipefail

LOCKFILE="/var/lock/daily_backup_2345.lock"
exec 9>"$LOCKFILE"

if ! flock -n 9; then
    echo "Error: Another instance of the daily backup is already running." >&2
    exit 1
fi

echo "[$(date -u)] Starting late-night daily database backup..."
# Simulate database backup
if pg_dump -U postgres prod_db > /backups/db_$(date +%F).sql; then
    echo "[$(date -u)] Daily backup completed successfully."
else
    echo "[$(date -u)] Daily backup failed!" >&2
    exit 2
fi
Setup notes

Save this script to /usr/local/bin/daily-backup.sh, make it executable with chmod +x, and add '45 23 * * * /usr/local/bin/daily-backup.sh' to your system crontab.

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(45 23 * * ? *)

Systemd Timer

OnCalendar*-*-* 23:45:00

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

[Timer]
OnCalendar=*-*-* 23:45:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

Why schedule a task at 23:45 instead of exactly midnight (00:00)?

Running at 23:45 staggers resource utilization, preventing contention with the high volume of automated tasks typically scheduled at exactly midnight. It also allows jobs to process and reconcile the current calendar day's data right before the date transitions.

How does Daylight Saving Time (DST) affect this schedule?

If your system uses local time, DST transitions in spring (clock forward) or autumn (clock back) can cause the job to either skip or run twice. To avoid this operational hazard, run your cron daemon or system orchestrator strictly on UTC.

What happens if the previous day's job takes more than 15 minutes?

If the task runs past midnight, it might overlap with early morning processes. It is critical to implement execution timeouts, optimize queries, and use locking mechanisms (like flock or Redis locks) to prevent concurrent executions.

Can I run this job only on weekdays?

Yes, you can modify the day-of-week field. To run at 11:45 PM from Monday through Friday, change the expression to '45 23 * * 1-5'.

How should I monitor the health of this daily job?

Implement dead man's snitches (heartbeat monitoring) where the script pings an external monitoring service upon completion. If the service doesn't receive a ping by 00:00, it triggers an alert for on-call engineers.

* Explore

Related expressions you might need

Last verified:

Was this helpful?