diff --git a/README.md b/README.md index 778eb15..504d004 100644 --- a/README.md +++ b/README.md @@ -46,16 +46,20 @@ Create a `config.yml` file in the same directory as the binary (or `/etc/scron/` ### Basic Configuration +Optionally, you can specify the `weekday` field (0=Sunday, 1=Monday, ..., 6=Saturday) to restrict jobs to specific days of the week. + ```yaml jobs: - name: "System Health Check" minute: "*/5" hour: "*" + weekday: "*" command: "curl -f http://localhost:8080/health || exit 1" - name: "Daily Backup" minute: "0" hour: "2" + weekday: "*" command: "/usr/local/bin/backup.sh" ``` @@ -98,19 +102,21 @@ jobs: - name: "Database Backup" minute: "0" hour: "3" + weekday: "*" command: "pg_dump mydb > /backup/mydb_$(date +%Y%m%d).sql" notification: default - name: "Critical Service Monitor" minute: "*/1" hour: "*" + weekday: "*" command: "systemctl is-active nginx || exit 1" notification: critical-only ``` -## Time Pattern Syntax +## Time Pattern Syntax (minute, hour, and optional weekday) -SCRON supports flexible cron-like time patterns for both minutes (0-59) and hours (0-23): +SCRON supports flexible cron-like time patterns for minutes (0-59), hours (0-23), and optional weekdays (0-6). 0 is Sunday, 1 is Monday, and so on: | Pattern | Description | Example | |---------|-------------|---------| @@ -130,33 +136,49 @@ jobs: - name: "Heartbeat" minute: "*" hour: "*" + weekday: "*" command: "echo 'alive'" # Every 5 minutes - name: "Frequent Check" minute: "*/5" hour: "*" + weekday: "*" command: "check-service.sh" # At specific minutes - name: "Quarter Hours" minute: "0,15,30,45" hour: "*" + weekday: "*" command: "quarter-hour-task.sh" # Business hours only (9 AM - 5 PM) - name: "Business Task" minute: "0" hour: "9-17" + weekday: "*" command: "business-process.sh" # Complex schedule - name: "Complex Task" minute: "5-55/10" # At 5, 15, 25, 35, 45, 55 hour: "8-18/2" # Every 2 hours from 8 AM to 6 PM + weekday: "*" command: "complex-task.sh" ``` +### Weekday Field Example + +```yaml +jobs: + - name: "Weekday Task" + minute: "0" + hour: "9" + weekday: "1-5" # Monday to Friday + command: "weekday-task.sh" +``` + ## Notification Configuration ### Gotify Configuration diff --git a/config.yml.example b/config.yml.example index c8b51b7..7e94d3b 100644 --- a/config.yml.example +++ b/config.yml.example @@ -2,4 +2,5 @@ jobs: - name: "Test" minute: "*" hour: "*" + weekday: "*" command: "echo 'Juhu'"