Schedule Weekly Monday Morning Tasks | CronBase
0 7 * * 1 Every week on Monday morning at seven o'clock.
This cron expression schedules a task to run once a week on Monday mornings at exactly seven o'clock. It is commonly used by operations teams to trigger weekly database maintenance, generate weekly business intelligence reports, warm up application caches before the workweek starts, or dispatch weekly summary emails to users.
- Minute
- 0
- Hour
- 7
- Day of Month
- *
- Month
- *
- Day of Week
- 1
Next 5 Runs
- in 1d 10h
- in 8d 10h
- in 15d 10h
- in 22d 10h
- in 29d 10h
* Tools
Code & Implementations
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status
set -euo pipefail
LOG_FILE="/var/log/weekly_backup.log"
echo "[$(date -u)] Starting weekly Monday morning maintenance..." >> "$LOG_FILE"
# Add your production-ready script logic here
if /usr/local/bin/run-database-backup --compress --upload-s3; then
echo "[$(date -u)] Maintenance completed successfully." >> "$LOG_FILE"
else
echo "[$(date -u)] ERROR: Maintenance failed! Sending alert..." >&2
# Trigger alerting mechanism (e.g., PagerDuty, Slack webhook)
exit 1
fi › Setup notes
Save this script to /usr/local/bin/weekly-maintenance.sh, make it executable with 'chmod +x', and add the following entry to your system crontab using 'crontab -e': 0 7 * * 1 /usr/local/bin/weekly-maintenance.sh
const cron = require('node-cron');
const { exec } = require('child_process');
console.log('Registering weekly Monday morning cron runner...');
// Schedule task to run at 07:00 every Monday
const task = cron.schedule('0 7 * * 1', () => {
console.log(`[${new Date().toISOString()}] Initiating weekly report compilation...`);
exec('/usr/bin/node /app/scripts/generate-weekly-reports.js', (error, stdout, stderr) => {
if (error) {
console.error(`[ERROR] Report generation failed: ${error.message}`);
return;
}
if (stderr) {
console.warn(`[WARN] Standard error output: ${stderr}`);
}
console.log(`[SUCCESS] Reports sent successfully: ${stdout.trim()}`);
});
}, {
scheduled: true,
timezone: "UTC"
}); › Setup notes
Install the node-cron package using 'npm install node-cron'. Ensure your application process is kept alive using a process manager like PM2 to guarantee execution.
import logging
import sys
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
# Setup production logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
handlers=[logging.StreamHandler(sys.stdout)]
)
def execute_weekly_sync():
logging.info("Starting weekly external API synchronization...")
try:
# Place your production synchronization or API polling logic here
logging.info("Synchronization completed successfully.")
except Exception as e:
logging.error(f"Failed to complete synchronization: {str(e)}", exc_info=True)
if __name__ == '__main__':
scheduler = BlockingScheduler()
# Standard cron '0 7 * * 1' maps to day_of_week='mon', hour=7, minute=0
trigger = CronTrigger(day_of_week='mon', hour=7, minute=0, timezone='UTC')
scheduler.add_job(execute_weekly_sync, trigger=trigger, id='weekly_sync_job')
logging.info("Scheduler initialized. Running weekly sync on Mondays at 07:00 UTC.")
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
logging.info("Scheduler stopped cleanly.") › Setup notes
Install the APscheduler library using 'pip install apscheduler'. Run this script as a persistent background daemon or inside a container.
package main
import (
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/robfig/cron/v3"
)
func main() {
logger := log.New(os.Stdout, "[CRON] ", log.LstdFlags|log.Lshortfile)
// Use UTC to avoid daylight saving time issues
location, err := time.LoadLocation("UTC")
if err != nil {
logger.Fatalf("Failed to load UTC timezone: %v", err)
}
c := cron.New(cron.WithLocation(location))
// AddFunc returns an entry ID and an error
_, err = c.AddFunc("0 7 * * 1", func() {
logger.Println("Executing weekly cache warmup routine...")
// Perform HTTP cache warmup requests here
logger.Println("Cache warmup routine completed successfully.")
})
if err != nil {
logger.Fatalf("Error scheduling weekly job: %v", err)
}
c.Start()
logger.Println("Cron engine started. Job scheduled for every Monday at 07:00 UTC.")
// Keep application running until interrupted
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
logger.Println("Stopping cron engine...")
c.Stop()
} › Setup notes
Initialize a Go module, run 'go get github.com/robfig/cron/v3', and execute this Go application as a long-running service.
package com.cronbase.scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.Instant;
@Component
public class WeeklyMaintenanceScheduler {
private static final Logger logger = LoggerFactory.getLogger(WeeklyMaintenanceScheduler.class);
// Spring Cron expression includes seconds. "0 0 7 * * MON" executes at 07:00:00 every Monday.
@Scheduled(cron = "0 0 7 * * MON", zone = "UTC")
public void runWeeklyCleanup() {
logger.info("Starting scheduled weekly database optimization at {}", Instant.now());
try {
// Implement your production database cleanup or index rebuild logic here
logger.info("Weekly database optimization completed successfully.");
} catch (Exception e) {
logger.error("Critical error during weekly database optimization: ", e);
// Trigger pager/alerting system
}
}
} › Setup notes
Ensure your Spring Boot application class is annotated with '@EnableScheduling'. This component will automatically be detected and scheduled by the Spring framework.
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekly-analytics-aggregation
namespace: production
spec:
schedule: "0 7 * * 1"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 5
startingDeadlineSeconds: 1800
jobTemplate:
spec:
template:
spec:
containers:
- name: aggregator
image: registry.example.com/analytics/aggregator:v1.4.2
imagePullPolicy: IfNotPresent
env:
- name: NODE_ENV
value: "production"
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "1000m"
memory: "1Gi"
restartPolicy: OnFailure › Setup notes
Save this manifest to a file named 'cronjob.yaml' and apply it to your cluster using 'kubectl apply -f cronjob.yaml'. Monitor executions using 'kubectl get cronjob -n production'.
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 7 ? * 1 *) Systemd Timer
OnCalendarMon *-*-* 07:00:00
[Unit]
Description=Timer for cron expression: 0 7 * * 1
[Timer]
OnCalendar=Mon *-*-* 07:00:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
How does Daylight Saving Time affect a Monday 7:00 AM cron job?
If your server runs on a timezone that observes DST, the job might run twice or be skipped during transition Sundays. To prevent this, run your servers and cron engines on UTC, which does not observe DST.
What happens if the server is offline at Monday 7:00 AM?
Standard cron does not retroactively run missed jobs. If your server is offline, the task is skipped until the next Monday. Use tools like anacron, systemd timers with Persistent=true, or Kubernetes CronJobs with startingDeadlineSeconds to handle offline recovery.
Is the day-of-week value 1 always interpreted as Monday?
Yes, in standard POSIX/Linux cron dialects, 1 represents Monday, and 7 or 0 represents Sunday. However, some systems like BSD or specific scheduler libraries might interpret 1 as Sunday. Always verify your specific scheduler's dialect documentation.
How can I test this cron schedule without waiting until Monday?
You can temporarily shift the cron expression to run a few minutes in the future (e.g., `*/5 * * * *`) to verify the script execution, or trigger the script manually directly from the command line while keeping the cron configuration intact.
Can I run this job on both Monday and Friday at 7:00 AM?
Yes, you can modify the day-of-week field to include multiple days using a comma. The expression `0 7 * * 1,5` will run the job at 7:00 AM on both Monday (1) and Friday (5).
* Explore
Related expressions you might need
Last verified: