Run Weekly Maintenance Tasks on Sunday | CronBase

cron expression Standard
$ 0 8 * * 0

Every Sunday morning at eight AM.

The `0 8 * * 0` cron expression schedules a task to execute every Sunday at exactly 8:00 AM. This weekly cadence is ideal for running low-traffic database backups, generating weekly performance reports, executing system updates, and conducting routine maintenance tasks without impacting standard weekday business operations.

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

Next 5 Runs

  • in 11h 34m
  • in 7d 11h
  • in 14d 11h
  • in 21d 11h
  • in 28d 11h

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Production Bash script for Sunday 8 AM Cron Job
# Usage: Add to crontab via: 0 8 * * 0 /path/to/script.sh >> /var/log/weekly_job.log 2>&1
set -euo pipefail
LOCKFILE="/var/run/weekly_maintenance.lock"
exec 200>"$LOCKFILE"
if ! flock -n 200; then
    echo "[$(date -u)] Error: Another instance of the weekly maintenance job is already running." >&2
    exit 1
fi
echo "[$(date -u)] Starting weekly maintenance tasks..."
# Add production tasks here (e.g., system cleanup, backup validation)
# Example: tar -czf /backups/weekly_$(date +%F).tar.gz /data
echo "[$(date -u)] Weekly maintenance completed successfully."
Setup notes

Save the script to your server, make it executable using 'chmod +x script.sh', and add it to your system crontab using 'crontab -e'.

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

Systemd Timer

OnCalendarSun *-*-* 08:00:00

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

[Timer]
OnCalendar=Sun *-*-* 08:00:00
Persistent=true

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How does Daylight Saving Time affect this Sunday 8 AM schedule?

Since the schedule runs at 8:00 AM, it is safely past the typical 2:00 AM DST shift. However, if your system clock shifts, the interval from the previous run may be 167 or 169 hours instead of 168. Ensure your cron daemon or scheduler is timezone-aware (using UTC is highly recommended) to avoid unexpected execution timing.

Is Sunday represented by 0 or 7 in standard cron systems?

In standard POSIX cron, 0 represents Sunday. However, many modern implementations (such as Vixie cron, BSD cron, and systemd) accept both 0 and 7 to represent Sunday. Using 0 is the most universally portable configuration across older legacy Unix environments.

What happens if the server is powered down at Sunday 8:00 AM?

Standard cron does not catch up on missed executions. If your server is offline at 8:00 AM on Sunday, the job will not run until the following Sunday. To mitigate this risk, use a utility like anacron for system tasks, or implement an external monitoring tool that alerts you when an expected weekly heartbeat is missed.

How should I handle long-running tasks scheduled at this time?

Since this job runs once a week, it has a large execution window before the next scheduled run. However, to prevent resource exhaustion or overlapping processes, wrap your script in a file lock utility like flock in Linux, or set a strict timeout within your application code.

Can I run this job on both Saturday and Sunday at 8:00 AM?

Yes, you can modify the day-of-week field to include both days. The expression '0 8 * * 0,6' or '0 8 * * 6-0' (depending on the parser) will trigger the execution at 8:00 AM on both Saturday (6) and Sunday (0), allowing you to run weekend-specific workflows.

* Explore

Related expressions you might need

Last verified:

Was this helpful?