Run Weekly Tasks Every Monday at Midnight | CronBase

cron expression Standard
$ 0 0 * * 1

Every single week at midnight on Monday morning

This standard cron expression schedules a task to execute every Monday at exactly midnight (00:00). It is widely used in production environments for weekly system maintenance, database indexing, log rotation, and generating business analytics reports before teams begin their workweek, ensuring clean system states and updated dashboards.

Minute
0
Hour
0
Day of Month
*
Month
*
Day of Week
1
How it works

Next 5 Runs

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

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
set -euo pipefail
# Operational cron script for weekly backup/maintenance
LOCKFILE="/var/lock/weekly_maintenance.lock"
exec 200>"$LOCKFILE"
if ! flock -n 200; then
    echo "Error: Another instance of this weekly job is already running." >&2
    exit 1
fi
echo "[$(date -u)] Starting weekly maintenance task..."
# Add production business logic here
# Example: tar -czf /backups/weekly_$(date +%F).tar.gz /data
echo "[$(date -u)] Weekly maintenance completed successfully."
Setup notes

Save this script to /usr/local/bin/weekly_maintenance.sh, make it executable using 'chmod +x', and add the cron entry using 'crontab -e' targeting '0 0 * * 1'.

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

Systemd Timer

OnCalendarMon *-*-* 00:00:00

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How do I handle daylight saving time changes with this weekly schedule?

To prevent duplicate or skipped executions during daylight saving time (DST) shifts, configure your cron daemon or orchestrator to run in Coordinated Universal Time (UTC). If local time is required, use a modern scheduler like systemd-timer or Kubernetes CronJobs that natively handles DST transitions.

What happens if the server is offline at Monday midnight?

Standard cron daemons will skip the execution entirely if the server is offline at the scheduled time. If guaranteed execution is critical, use tools like `anacron` on Linux, or implement idempotent jobs with a queue-based scheduler that triggers missed runs upon system startup.

How can I prevent multiple weekly jobs from overloading the database at this time?

Implement a randomized startup delay or jitter (e.g., sleeping for a random duration between 1 and 10 minutes) at the beginning of your job execution. This distributes the database load and prevents resource contention from concurrent cron tasks.

Is it safe to use this schedule for log rotation?

Yes, this is a common pattern for weekly log rotation. However, ensure that logrotate or your custom script has a lock mechanism (such as `flock`) to prevent concurrent instances from running if a previous rotation hangs, and verify that services are gracefully reloaded to release file handles.

How does standard cron interpret the day-of-week field value of 1?

In the standard cron specification, the day-of-week field value of 1 represents Monday. Note that while 0 and 7 both represent Sunday in many modern implementations, 1 consistently and unambiguously represents Monday across all standard UNIX platforms.

* Explore

Related expressions you might need

Last verified:

Was this helpful?