I'm back with another #FreeBSD question, specifically about `periodic`. I'd like to use `periodic daily` to occasionally scrub my ZFS pools by setting `daily_scrub_zfs_enable` to `"YES"` in `/etc/periodic.conf`. This works great on a server, because it's always on, but not so great on my laptop, because the cron is scheduled at night. I could change the time, but then it'll only run if my laptop is on at the right time.

Is there a way to schedule this so the `periodic` crons are run after booting, in case there are "missed" runs? What is the recommended approach here, use e.g. Xfce's autostart applications for this?

Edit: solved! The answer is anacron

Thanks for reading :)

#cron #periodic #zfs

@kedara install the package "anacron" and configure it to run the periodic scripts instead of cron. It's been a long time since I set up my laptop like this, but the instructions are pretty straightforward, as I recall #freebsd
@djfiander I think this is exactly what I was looking for. Thanks a lot!

@kedara Could directly run the actual ZFS scrub script on boot via "crontab(5)" ...

@reboot -n sleep 134 && /etc/periodic/daily/800.scrub-zfs

... with "daily_scrub_zfs_enable"d (🙄preferable would be to refactor the part for the "case" of "[Yy][Ee][Ss]" in its own script in order to not have to rely on extra moving part).

@ax6761 thanks, I went with anacron: easy to setup, and now I can make full use of other periodic scripts.
@kedara
Is there a package called 'anacron' within #FreeBSD ?
I think it could answer your needs.
@blotza thank you, I got that suggestion, should have edited my post. It's indeed what I was looking for!

@kedara I don't know if there is a "correct" way to do this, but periodic is launched by cron. Here's the relevant line from my /etc/crontab:

1 3 * * * root periodic daily

You should be able to edit yours to something like this:

@reboot root periodic

@uastronomer thank you, that could also work, I've gone with anacron and edited the post.