Run Weekly Tasks Every Monday at 9 AM | CronBase
0 9 * * 1 Every Monday morning at nine o clock
The `0 9 * * 1` cron expression schedules a task to execute automatically every Monday at exactly 9:00 AM. This weekly cadence is widely used in enterprise environments to trigger weekly status reports, initiate system diagnostic routines, clear temporary caches from the weekend, and dispatch automated team notifications at the start of the business week.
- Minute
- 0
- Hour
- 9
- Day of Month
- *
- Month
- *
- Day of Week
- 1
Next 5 Runs
- in 1d 12h
- in 8d 12h
- in 15d 12h
- in 22d 12h
- in 29d 12h
* Tools
Code & Implementations
#!/usr/bin/env bash
# Production-ready Bash script to install a crontab entry
set -euo pipefail
CRON_SCHEDULE="0 9 * * 1"
JOB_COMMAND="/usr/local/bin/weekly-report-generator.sh >> /var/log/weekly-report.log 2>&1"
echo "Configuring cron job for weekly execution..."
# Check if crontab exists, if not create an empty one
current_cron=$(crontab -l 2>/dev/null || true)
# Avoid duplicate entries
if echo "$current_cron" | grep -Fq "$JOB_COMMAND"; then
echo "Cron job already exists. Skipping installation."
else
(echo "$current_cron"; echo "$CRON_SCHEDULE $JOB_COMMAND") | crontab -
echo "Cron job successfully installed."
fi › Setup notes
Save this script to a file, make it executable with chmod +x, and run it as the user who should execute the weekly cron task.
// Ensure you have installed node-cron: npm install node-cron
const cron = require('node-cron');
const { exec } = require('child_process');
// Schedule the weekly task for Monday at 9:00 AM
const schedule = '0 9 * * 1';
console.log(`Initializing scheduler with pattern: ${schedule}`);
const task = cron.schedule(schedule, () => {
const timestamp = new Date().toISOString();
console.log(`[${timestamp}] Starting weekly reporting job...`);
exec('/usr/local/bin/weekly-report.sh', (error, stdout, stderr) => {
if (error) {
console.error(`[${timestamp}] Job execution failed:`, error.message);
return;
}
if (stderr) {
console.warn(`[${timestamp}] Job stderr output:`, stderr);
}
console.log(`[${timestamp}] Job completed successfully. Output:\n`, stdout);
});
}, {
scheduled: true,
timezone: "UTC"
}); › Setup notes
Run this script inside a persistent Node.js process manager like PM2 to guarantee continuous execution and automatic restarts.
# Production-ready weekly scheduler using APScheduler
# Required dependency: pip install apscheduler
import logging
import sys
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
handlers=[logging.StreamHandler(sys.stdout)]
)
def run_weekly_job():
logging.info("Executing weekly maintenance and reporting task...")
try:
# Simulate business logic
logging.info("Weekly task completed successfully.")
except Exception as e:
logging.error(f"Failed to execute weekly task: {str(e)}")
if __name__ == "__main__":
scheduler = BlockingScheduler()
# 0 9 * * 1 translates to: day_of_week='mon', hour=9, minute=0
trigger = CronTrigger(day_of_week='mon', hour=9, minute=0, timezone='UTC')
scheduler.add_job(
run_weekly_job,
trigger=trigger,
id='weekly_maintenance_job',
replace_existing=True
)
logging.info("Scheduler started. Running weekly job at 9:00 AM UTC every Monday.")
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
logging.info("Scheduler stopped cleanly.") › Setup notes
Execute this Python script in a dedicated virtual environment. Ensure the container or daemon host remains online to trigger the job.
package main
import (
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/robfig/cron/v3"
)
func main() {
logger := log.New(os.Stdout, "[WeeklyScheduler] ", log.LstdFlags|log.Lshortfile)
logger.Println("Initializing cron runner...")
// Use UTC timezone for standard, predictable execution times
c := cron.New(cron.WithLocation(time.UTC))
// 0 9 * * 1: Every Monday at 09:00
_, err := c.AddFunc("0 9 * * 1", func() {
logger.Println("Starting weekly database maintenance and report generation...")
// Execute production logic here
logger.Println("Weekly tasks completed successfully.")
})
if err != nil {
logger.Fatalf("Failed to schedule cron job: %v", err)
}
c.Start()
logger.Println("Scheduler running. Waiting for Monday 09:00 UTC...")
// Graceful shutdown handling
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
logger.Println("Shutting down scheduler...")
c.Stop()
logger.Println("Scheduler stopped cleanly.")
} › Setup notes
Compile the Go application and deploy it as a systemd service or run it inside a Docker container to ensure continuous uptime.
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 WeeklyTaskScheduler {
private static final Logger logger = LoggerFactory.getLogger(WeeklyTaskScheduler.class);
/**
* Executes every Monday at 9:00 AM.
* Cron format: second, minute, hour, day of month, month, day(s) of week
* Spring cron uses 6 fields (adding seconds at the start).
*/
@Scheduled(cron = "0 0 9 * * MON", zone = "UTC")
public void executeWeeklyJob() {
logger.info("Weekly maintenance job started at Monday 9:00 AM UTC.");
try {
performBusinessLogic();
logger.info("Weekly maintenance job completed successfully.");
} catch (Exception e) {
logger.error("Error occurred during weekly maintenance execution", e);
}
}
private void performBusinessLogic() {
// Implement database cleanup, report generation, or email dispatch here
}
} › Setup notes
Ensure Spring's @EnableScheduling annotation is declared on your main Application configuration class to activate this scheduler.
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekly-reporting-job
namespace: default
labels:
app: weekly-reporter
spec:
schedule: "0 9 * * 1"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
startingDeadlineSeconds: 600
jobTemplate:
spec:
template:
metadata:
labels:
app: weekly-reporter
spec:
containers:
- name: reporter
image: curlimages/curl:7.85.0
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
echo "Starting weekly report generation..."
curl -fsS --retry 3 https://api.internal.services/reports/generate-weekly
echo "Weekly report successfully triggered."
restartPolicy: OnFailure › Setup notes
Apply this manifest using kubectl apply -f. This configuration ensures that only one job runs at a time and tracks historical outcomes.
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 9 ? * 1 *) Systemd Timer
OnCalendarMon *-*-* 09:00:00
[Unit]
Description=Timer for cron expression: 0 9 * * 1
[Timer]
OnCalendar=Mon *-*-* 09:00:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
What happens if the host machine is powered off on Monday at 9:00 AM?
Standard cron daemons will completely miss the execution window if the host is powered off at 9:00 AM. Unlike anacron, which catches up on missed jobs upon reboot, standard cron will not run the task until the following Monday at 9:00 AM. For critical jobs, consider using anacron or Kubernetes CronJobs with a configured startingDeadlineSeconds.
How can I handle Daylight Saving Time (DST) changes with this schedule?
If your system timezone is set to a local timezone that observes DST, the execution will shift relative to UTC. To maintain a strict execution time regardless of seasonal shifts, configure your server or application scheduler to run on UTC, or use a timezone-aware scheduling library.
Can I run this job on multiple nodes simultaneously without duplication?
Running standard cron on multiple servers will cause duplicate executions. To prevent this in a clustered environment, you must use a distributed locking mechanism (like Redis-based Redlock or database locks) or run the job within an orchestrator like Kubernetes with a Forbid concurrency policy.
How can I test this cron job without waiting until next Monday?
You can trigger the job manually by executing the underlying command or script directly. In Kubernetes, you can create a job from the CronJob template using: kubectl create job --from=cronjob/weekly-reporting-job manual-test-run
Is it possible to schedule this job to run at 9:00 AM in the user's local timezone?
Standard cron cannot dynamically adjust to different users' timezones. You must either run a centralized job that handles timezone math programmatically, or deploy multiple cron schedules across regional servers configured to their respective local times.
* Explore
Related expressions you might need
Last verified: