docs: weekday in readme and sample config
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
kekskurse 2025-08-06 18:36:25 +02:00
parent e84340df2c
commit c5198ed241
2 changed files with 25 additions and 2 deletions

View file

@ -46,16 +46,20 @@ Create a `config.yml` file in the same directory as the binary (or `/etc/scron/`
### Basic Configuration ### 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 ```yaml
jobs: jobs:
- name: "System Health Check" - name: "System Health Check"
minute: "*/5" minute: "*/5"
hour: "*" hour: "*"
weekday: "*"
command: "curl -f http://localhost:8080/health || exit 1" command: "curl -f http://localhost:8080/health || exit 1"
- name: "Daily Backup" - name: "Daily Backup"
minute: "0" minute: "0"
hour: "2" hour: "2"
weekday: "*"
command: "/usr/local/bin/backup.sh" command: "/usr/local/bin/backup.sh"
``` ```
@ -98,19 +102,21 @@ jobs:
- name: "Database Backup" - name: "Database Backup"
minute: "0" minute: "0"
hour: "3" hour: "3"
weekday: "*"
command: "pg_dump mydb > /backup/mydb_$(date +%Y%m%d).sql" command: "pg_dump mydb > /backup/mydb_$(date +%Y%m%d).sql"
notification: default notification: default
- name: "Critical Service Monitor" - name: "Critical Service Monitor"
minute: "*/1" minute: "*/1"
hour: "*" hour: "*"
weekday: "*"
command: "systemctl is-active nginx || exit 1" command: "systemctl is-active nginx || exit 1"
notification: critical-only 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 | | Pattern | Description | Example |
|---------|-------------|---------| |---------|-------------|---------|
@ -130,33 +136,49 @@ jobs:
- name: "Heartbeat" - name: "Heartbeat"
minute: "*" minute: "*"
hour: "*" hour: "*"
weekday: "*"
command: "echo 'alive'" command: "echo 'alive'"
# Every 5 minutes # Every 5 minutes
- name: "Frequent Check" - name: "Frequent Check"
minute: "*/5" minute: "*/5"
hour: "*" hour: "*"
weekday: "*"
command: "check-service.sh" command: "check-service.sh"
# At specific minutes # At specific minutes
- name: "Quarter Hours" - name: "Quarter Hours"
minute: "0,15,30,45" minute: "0,15,30,45"
hour: "*" hour: "*"
weekday: "*"
command: "quarter-hour-task.sh" command: "quarter-hour-task.sh"
# Business hours only (9 AM - 5 PM) # Business hours only (9 AM - 5 PM)
- name: "Business Task" - name: "Business Task"
minute: "0" minute: "0"
hour: "9-17" hour: "9-17"
weekday: "*"
command: "business-process.sh" command: "business-process.sh"
# Complex schedule # Complex schedule
- name: "Complex Task" - name: "Complex Task"
minute: "5-55/10" # At 5, 15, 25, 35, 45, 55 minute: "5-55/10" # At 5, 15, 25, 35, 45, 55
hour: "8-18/2" # Every 2 hours from 8 AM to 6 PM hour: "8-18/2" # Every 2 hours from 8 AM to 6 PM
weekday: "*"
command: "complex-task.sh" 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 ## Notification Configuration
### Gotify Configuration ### Gotify Configuration

View file

@ -2,4 +2,5 @@ jobs:
- name: "Test" - name: "Test"
minute: "*" minute: "*"
hour: "*" hour: "*"
weekday: "*"
command: "echo 'Juhu'" command: "echo 'Juhu'"