When to run periodic scripts ?

Hi forum
I'm mostly using FreeBSD with KDE Plasma as my daily desktop. Works nicely.
To save a few electrons I usually poweroff each evening before going home, so this system does NOT run 24/7/365.
I can see the periodic housekeeping scripts are scheduled to run soon after 3.0 am.
This doesn't quite suit my use case.
Please, when would be a better time for me to schedule these housekeeping tasks in crontab ?
Should something be run when powering up, ie @reboot ?
Or perhaps as part of a shutdown script ?
Or some other time/s ?
Thanks for any tips or clues.
 
That's a tough question. Some of the periodic scripts are very fast, some can take long (like the locate database). Quite a few of them are IO intensive, so they stress the disk. Try the following sometime: while doing your normal everyday work (whatever that might be), run them by hand; I think just becoming root and saying "periodic daily" (or monthly or weekly) will work. Continue working, and see whether they really badly go on your nerves with performance degradation. If you have a fast disk (SSD? NVME?) you might not even notice. If you have a big system and slow disks, you will probably get very annoyed. And measure how long they take.

Depending on the answer:
  • If they are perfectly fine to run while you are doing your normal work, just run them then and there. For example, if you typically use your computer from 9am till 5pm, set them to run at 10am (and 10:15 and 10:30).
  • Maybe if you usually take a lunch break, set them to start at 12:05 noon, and if you're lucky they'll be done by the time your pizza is heated and eaten.
  • If they can't be run during normal work hours (or lunch break):
  • When powering up? Probably not, because you probably just powered up the computer because you need it NOW.
  • When shutting down? That's probably the best idea.
A nice idea might be to write a script that you can use to replace shutdown, which runs whatever periodic hasn't been run recently enough, and then shuts down; but if you get unlucky (your computer has been off for a week due to vacation, and you turn it on on April 3rd), it might take many hours before shutdown finishes. If the noise of the computer running is a problem, this might be a bad idea.

On my home server, daily (takes less than 10 minutes, which includes doing the locate database, I moved that from weekly. Then weekly and monthly take a few minutes each. I start them at 1:15am and 1:45am (when I'm very likely asleep), so they finish before the hourly backup (which runs every hour, exactly on the hour). I noticed that running zpool scrub simultaneously with the locate database update or my hourly backup is noticeable, and running all three at once is painful. I'm using spinning disks though.
 
Back
Top