Run Weekly Friday Evening Jobs at 6 PM | CronBase
0 18 * * 5 Every Friday evening at six PM
This cron expression schedules a task to run weekly every Friday evening at exactly 6:00 PM. It is commonly deployed in production environments for end-of-week reporting, automated database backups before weekend low-traffic periods, and initiating scheduled maintenance windows that require system-wide validation before operations resume on Monday morning.
- Minute
- 0
- Hour
- 18
- Day of Month
- *
- Month
- *
- Day of Week
- 5
Next 5 Runs
- in 5d 21h
- in 12d 21h
- in 19d 21h
- in 26d 21h
- in 33d 21h
* Tools
Code & Implementations
#!/usr/bin/env bash
# Friday evening backup and maintenance script
set -euo pipefail
LOG_FILE="/var/log/friday_backup.log"
exec >> "$LOG_FILE" 2>&1
echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] Starting weekly maintenance job..."
# Add actual production backup or cleanup logic here
# Example: pg_dump -U postgres dbname > /backups/weekly_$(date +%F).sql
echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] Weekly job completed successfully." › Setup notes
Save the code as /usr/local/bin/weekly-backup.sh, make it executable with 'chmod +x', and register it in your crontab using '0 18 * * 5 /usr/local/bin/weekly-backup.sh'.
const cron = require('node-cron');
const logger = require('./logger'); // Assume custom logging module
// Schedule task to run at 18:00 (6 PM) every Friday
cron.schedule('0 18 * * 5', async () => {
logger.info('Starting weekly Friday evening maintenance task...');
try {
await runWeeklyMaintenance();
logger.info('Weekly maintenance task completed successfully.');
} catch (error) {
logger.error('Failed to execute weekly maintenance task:', error);
// Trigger alerting system (e.g., PagerDuty, Slack webhook)
}
}, {
scheduled: true,
timezone: "Etc/UTC"
});
async function runWeeklyMaintenance() {
// Production maintenance/reporting logic goes here
} › Setup notes
Install the dependency using 'npm install node-cron', ensure your logger is configured, and run this script as a long-running daemon process.
import logging
import sys
from datetime import datetime
# Configure production logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
handlers=[
logging.FileHandler("/var/log/weekly_job.log"),
logging.StreamHandler(sys.stdout)
]
)
def execute_weekly_job():
logging.info("Initiating weekly Friday 6 PM database optimization...")
try {
# Place actual production database optimization or cleanup here
pass
logging.info("Weekly database optimization completed successfully.")
except Exception as e:
logging.error(f"Weekly job failed: {str(e)}", exc_info=True)
sys.exit(1)
if __name__ == "__main__":
execute_weekly_job() › Setup notes
Save this script to your server and trigger it using standard system cron by adding '0 18 * * 5 /usr/bin/python3 /path/to/script.py' to your crontab.
package main
import (
"log"
"os"
"time"
"github.com/robfig/cron/v3"
)
func main() {
logger := log.New(os.Stdout, "CRON_WEEKLY: ", log.LstdFlags|log.Lshortfile)
// Use UTC timezone explicitly for production predictability
nyc, err := time.LoadLocation("America/New_York")
if err != nil {
logger.Fatalf("Failed to load timezone: %v", err)
}
c := cron.New(cron.WithLocation(nyc))
// 0 18 * * 5 represents 18:00 on Friday
_, err = c.AddFunc("0 18 * * 5", func() {
logger.Println("Starting scheduled Friday 6 PM job...")
if err := runWeeklyTask(); err != nil {
logger.Printf("Error during weekly task execution: %v", err)
// Implement alerting/monitoring dispatch here
} else {
logger.Println("Friday 6 PM job completed successfully.")
}
})
if err != nil {
logger.Fatalf("Error scheduling cron job: %v", err)
}
c.Start()
select {} // Keep application running
}
func runWeeklyTask() error {
// Production task logic
return nil
} › Setup notes
Initialize your Go module, fetch the cron library using 'go get github.com/robfig/cron/v3', and build/run the binary as a background 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);
// Spring's @Scheduled uses a 6-field cron pattern: second, minute, hour, day, month, day-of-week
@Scheduled(cron = "0 0 18 * * FRI", zone = "UTC")
public void runFridayEveningMaintenance() {
logger.info("Executing Friday evening maintenance job...");
try {
executeMaintenanceTasks();
logger.info("Friday evening maintenance completed successfully.");
} catch (Exception e) {
logger.error("Error executing Friday evening maintenance: ", e);
// Send alert to on-call engineer
}
}
private void executeMaintenanceTasks() throws Exception {
// Production-grade batch processing or cleanup logic
}
} › Setup notes
Ensure '@EnableScheduling' is declared on your main Spring Boot application class, then place this component in your project's component-scan path.
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekly-friday-cleanup
namespace: production
spec:
schedule: "0 18 * * 5"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 5
jobTemplate:
spec:
template:
spec:
containers:
- name: cleanup-worker
image: postgres:15-alpine
command:
- /bin/sh
- -c
- "echo 'Starting weekly vacuum...'; vacuumdb -h db-service -U postgres -a -z"
env:
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
restartPolicy: OnFailure › Setup notes
Apply this manifest to your cluster using 'kubectl apply -f cronjob.yaml'. Ensure the referenced database credentials secret is provisioned in the 'production' namespace.
Last verified:
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.
cron(0 18 ? * 5 *) Systemd Timer
OnCalendarFri *-*-* 18:00:00
[Unit]
Description=Timer for cron expression: 0 18 * * 5
[Timer]
OnCalendar=Fri *-*-* 18:00:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
How does daylight saving time affect a Friday 6 PM cron job?
If your server is set to a local timezone that observes DST, the execution time will shift relative to UTC. To prevent unexpected shifts in business logic, set your cron runner to a fixed timezone like UTC, or ensure your scheduling library explicitly handles DST transitions.
What happens if the server is offline at Friday 18:00?
Standard cron engines (like Vixie cron) do not catch up on missed executions. If your server is offline, the job is skipped entirely until the next Friday. For critical jobs, use an orchestrator like Kubernetes CronJobs with a startingDeadlineSeconds policy, or an external scheduling service.
Can I run this job on both Friday and Saturday at 6 PM?
Yes, you can modify the day-of-week field to include both days. In standard cron, changing the expression to 0 18 * * 5,6 will trigger the job at 6 PM on both Friday (5) and Saturday (6).
How can I safely test this weekly cron job without waiting for Friday?
You should separate your job's execution logic from the scheduling configuration. Test the logic independently by running the script or container manually in a staging environment, and use cron parsing tools to validate that the expression resolves to the correct upcoming Friday.
Is it safe to run heavy database migrations using this schedule?
While Friday at 6 PM is often a low-traffic window for B2B applications, running heavy migrations then can ruin your weekend if things go wrong. It is best practice to run migrations during low-traffic hours with active developer supervision, or use blue-green deployments rather than relying on unmonitored Friday night cron jobs.
* Explore
Related expressions you might need
Last verified: