Run Sunday at 1 AM Cron Schedule Guide | CronBase
0 1 * * 0 Every Sunday morning at one AM
This cron expression schedules a task to execute every Sunday at exactly 1:00 AM. It is commonly used in production environments for heavy weekly operations such as full database backups, log rotation, system updates, and report generation, when traffic and user activity are typically at their lowest.
- Minute
- 0
- Hour
- 1
- Day of Month
- *
- Month
- *
- Day of Week
- 0
Next 5 Runs
- in 4h 35m
- in 7d 4h
- in 14d 4h
- in 21d 4h
- in 28d 4h
* Tools
Code & Implementations
#!/usr/bin/env bash
# Weekly system backup cron job scheduled for 1:00 AM on Sundays
set -euo pipefail
LOG_FILE="/var/log/weekly_backup.log"
log() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')] $1" >> "$LOG_FILE"
}
log "Starting weekly backup process..."
# Perform backup operation
if tar -czf /backups/weekly_$(date +%F).tar.gz /data >> "$LOG_FILE" 2>&1; then
log "Backup completed successfully."
else
log "ERROR: Backup failed!"
exit 1
fi › Setup notes
Add this script to /usr/local/bin/weekly-backup.sh, make it executable with chmod +x, and add 0 1 * * 0 /usr/local/bin/weekly-backup.sh to the root crontab.
const cron = require('node-cron');
const { exec } = require('child_process');
// Schedule task to run every Sunday at 1:00 AM
cron.schedule('0 1 * * 0', () => {
console.log(`[${new Date().toISOString()}] Initiating weekly database maintenance...`);
exec('npm run db:maintenance', (error, stdout, stderr) => {
if (error) {
console.error(`Maintenance failed: ${error.message}`);
return;
}
if (stderr) {
console.warn(`Maintenance warnings: ${stderr}`);
}
console.log(`Maintenance output: ${stdout}`);
});
}, {
scheduled: true,
timezone: "UTC"
}); › Setup notes
Install the node-cron package using npm install node-cron. Run this script as a daemon using a process manager like PM2 to ensure continuous execution.
import logging
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def weekly_cleanup_job():
logger.info("Starting weekly cleanup and optimization job...")
try:
# Simulate cleanup logic
logger.info("Database indexes rebuilt successfully.")
except Exception as e:
logger.error(f"Cleanup job failed: {str(e)}")
if __name__ == "__main__":
scheduler = BlockingScheduler()
# 0 1 * * 0 translates to day_of_week='sun', hour=1, minute=0
scheduler.add_job(weekly_cleanup_job, 'cron', day_of_week='sun', hour=1, minute=0, timezone='UTC')
logger.info("Scheduler started. Job configured for Sundays at 1:00 AM UTC.")
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
logger.info("Scheduler stopped.") › Setup notes
Install APScheduler via pip install apscheduler. Run this script in a dedicated background worker or container to manage weekly tasks.
package main
import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/robfig/cron/v3"
)
func main() {
// Use UTC to avoid DST shift issues
nyc, err := time.LoadLocation("UTC")
if err != nil {
log.Fatalf("Failed to load timezone: %v", err)
}
c := cron.New(cron.WithLocation(nyc))
// 0 1 * * 0: Every Sunday at 1:00 AM
_, err = c.AddFunc("0 1 * * 0", func() {
fmt.Printf("[%s] Running weekly report generation...\n", time.Now().Format(time.RFC3339))
// Implement report generation logic here
})
if err != nil {
log.Fatalf("Error scheduling job: %v", err)
}
c.Start()
log.Println("Cron scheduler started. Waiting for Sunday at 1:00 AM...")
// Keep application running until interrupted
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
log.Println("Shutting down scheduler...")
c.Stop()
} › Setup notes
Initialize a Go module, run go get github.com/robfig/cron/v3, and compile the binary. Run the compiled binary as a persistent systemd service.
package com.example.scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class WeeklyMaintenanceScheduler {
private static final Logger logger = LoggerFactory.getLogger(WeeklyMaintenanceScheduler.class);
// "0 1 * * 0" in standard cron translates to "0 0 1 * * SUN" in Spring (which includes seconds)
@Scheduled(cron = "0 0 1 * * SUN", zone = "UTC")
public void runWeeklyMaintenance() {
logger.info("Weekly maintenance job started at 1:00 AM Sunday UTC");
try {
performDatabaseVacuum();
logger.info("Weekly maintenance completed successfully.");
} catch (Exception e) {
logger.error("Error during weekly maintenance execution", e);
}
}
private void performDatabaseVacuum() {
// Logic to optimize database storage
}
} › Setup notes
Ensure @EnableScheduling is added to your Spring Boot main application class. The job is configured to run safely using the UTC timezone.
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekly-database-cleanup
namespace: production
spec:
schedule: "0 1 * * 0"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 5
jobTemplate:
spec:
template:
spec:
containers:
- name: cleanup-worker
image: postgres:15-alpine
command:
- /bin/sh
- -c
- "vacuumdb -U postgres -d main_production -z"
env:
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
restartPolicy: OnFailure › Setup notes
Apply this manifest using kubectl apply -f cronjob.yaml. The concurrencyPolicy: Forbid setting prevents overlapping runs if a task takes longer than a week.
Last verified:
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.
cron(0 1 ? * 0 *) Systemd Timer
OnCalendarSun *-*-* 01:00:00
[Unit]
Description=Timer for cron expression: 0 1 * * 0
[Timer]
OnCalendar=Sun *-*-* 01:00:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
How does the Sunday 1 AM schedule behave during Daylight Saving Time transitions?
If running in a local timezone that observes DST, the transition forward (spring) or backward (autumn) typically occurs at 2:00 AM. While 1:00 AM is generally safe from being skipped, shifting system clocks can still cause execution timing anomalies. To guarantee consistent weekly intervals, configure your scheduler or server environment to run in UTC.
What happens if the server is offline when Sunday 1:00 AM passes?
Standard cron daemons will not run missed jobs once the server comes back online. If missed execution recovery is critical (e.g., for financial reconciliations or backups), you should use an anacron-like utility, systemd timers with 'Persistent=true', or a Kubernetes CronJob configuration.
How can I prevent multiple instances of this weekly job from overlapping?
Since this job runs once a week, overlapping is rare unless a task hangs indefinitely. Implement flock-based locking in Bash, use the 'concurrencyPolicy: Forbid' setting in Kubernetes, or use database-backed distributed locks (like ShedLock in Java or Redlock in Redis) for application-level tasks.
Can I run this job on a different day of the week instead of Sunday?
Yes. The final field in the standard five-field cron expression controls the day of the week. Changing the '0' to '1' will run the job on Monday, '5' will run it on Friday, and '6' will run it on Saturday. The execution time will remain at 1:00 AM.
How should I monitor a job that only runs once a week?
Passive monitoring (waiting for an error alert) is risky for weekly jobs because a failure means a whole week without execution. Implement active 'dead-man's switch' monitoring using services like Healthchecks.io, Opsgenie, or Prometheus Pushgateway, which alert you if a success signal is NOT received by 1:15 AM every Sunday.
* Explore
Related expressions you might need
Last verified: