Cron Schedule

ky41083

Member
Apr 5, 2021
12
4
23
42
Just did a fresh install of PVE. Going over the stock cron jobs I found this:

In /etc/cron.d/zfsutils-linux

Bash:
# TRIM the first Sunday of every month.
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi

Actually works out to the following schedule, as opposed to being the first Sunday of every month as the comment line suggests:
“At 00:24 on every day-of-month from 1 through 7.”

Per https://crontab.guru/#24_0_1-7_*_*

The scrub job in the same file is similarly mismatched. Is the schedule in the comment line, or the schedule in the actual job how it's intended to run?
 
Bash:
# TRIM the first Sunday of every month.
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi

Actually works out to the following schedule, as opposed to being the first Sunday of every month as the comment line suggests:
“At 00:24 on every day-of-month from 1 through 7.”
Yes but there is an additional check for sundays: [ $(date +\%w) -eq 0 ]. Therefore, if “At 00:24 on every day-of-month from 1 through 7.” and it's a Sunday (and trim exists), then run trim. The Sunday that is in one of the first 7 days of the month, is the first Sunday of the month.
 
  • Like
Reactions: ky41083