Question about system schedules

Dunuin

Distinguished Member
Jun 30, 2020
14,793
4,607
258
Germany
Hi,

What maintenance tasks is PVE running out of the box and what has to be set up by us manually?

Some examples:

1.) looks like LXCs stored on LVM-Thin can't do fstrim/discard from inside the LXC and it is needed to run pct fstrim for all these LXCs from time to time on the host. PVE isn't doing that on its own right?
I added this myself adding this to crontab:
Code:
# hourly trim of all LXCs, but not at 06:00 where backups might run, because otherwise, the backup will fail, as pct strim locks the LXCs
0 0-5,7-23 *   *   *   /sbin/pct list | awk '/^[0-9]/ {print $1}' | while read ct; do pct fstrim ${ct}; done >/var/log/cron.log 2>&1
And looks like pct fstrim will fail on LXCs stored on ZFS. Is there also a script that will only do a pct fstrim for all LXCs only stored on LVM thin?

2.) updating the list of downloadable LXC templates. Is PVE already doing that?
I added this to crontab:
Code:
# update LXC template list every Sunday at 00:00:
0 0    *   *   0   /usr/bin/pveam update >/var/log/cron.log 2>&1

3.) daily fstrim of the PVE root filesystem. If I understand it right, then the fstrim.timer is already doing a weekly fstrim out of the box.
I added this script to "/etc/cron.daily/daily_trim":
Code:
#!/bin/sh
#
# To find which FS support trim, we check that DISC-MAX (discard max bytes)
# is great than zero. Check discard_max_bytes documentation at
# https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
#
# Copy script to /etc/cron.daily or /etc/cron.weekly
#
for fs in $(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print $1}'); do
        fstrim "$fs"
done

And then added this to the crontab to run it, because otherwise, it wouldn't run automatically. Maybe someone knows why putting a script in "/etc/cron.daily/" won't make it run daily, without the additional cron entry?:
Code:
# daily fstrim
0 0    *   *   *   /bin/sh /etc/cron.daily/daily_trim >/var/log/cron.log 2>&1

4.) weekly scrub of the ZFS pools. Is PVE already scrubbing? According to openzfs this is usually done by creating a timer like "zfs-scrub-weekly@rpool.timer" but looks like PVE doesn't come with these enabled. If that doesn't come out of the box it really should be automatically added when installing PVE on rpool or adding a new ZFS pool using the webUI/API. So many people just want to use ZFS as a simple software raid without actually learning how to use and maintain it.
Added this to the crontab:
Code:
# weekly scrub of rpool
0 8    *   *   0   /usr/sbin/zpool scrub rpool >/var/log/cron.log 2>&1

5.) Do I understand it correctly, that the e2scrub_all.timer is scrubbing LVM-thin pools?

6.) There is also a pve-daily-update.timer that runs "/usr/bin/pveupdate".
Never coded with perl but looks like it is updating the subscription and SSL certificate.

Anything else that should be done on a regular basis to maintain PVE that I'm missing?
 
And looks like pct fstrim will fail on LXCs stored on ZFS. Is there also a script that will only do a pct fstrim for all LXCs only stored on LVM thin?
ZFS datasets (not zvol!) are thin by default, so TRIM makes no sense.

Maybe someone knows why putting a script in "/etc/cron.daily/" won't make it run daily, without the additional cron entry?:
You have to adhere to the requirements off run-parts. Please refer to cron(8) for specific information about correct permissions and file naming scheme.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!