"seaf-gc.sh" should be runnable by "root" just like "seaf-fsck.sh"

I see no reason “seaf-gc.sh” should not process when invoked by “root”. I use “cron” to invoke “seaf-fsck.sh” to Export my Libraries for Backup. It must run as “root” and does run as “root”! But, “seaf-gc.sh” simply fails when invoked by “root”. I would really like to be able to delete unused blocks at the same time but can’t. CORRECTION: “seaf-fsck.sh” also fails when invoked by “root” so is consistent with “seaf-gc.sh”. END CORRECTION

By the way, …DIRECTORY-date +"%Y-%m-%d%H-%M-%S"… (This forum won’t accept the exact syntax so look it up!) works in the “seaf-fsck.sh” script exactly like in the “CP Command” which is really nice! You may want to consider updating your documentation so everyone knows.

Why are you requiring the script to be ran as root?

The “cron” script: Stops the Seafile Server (systemctl), Mounts the “Vault” Partition (mount), … invokes “seaf-fsck.sh” to Backup the Seafile Libraries … , Unmounts the “Vault” Partition (umount) and Starts the Seafile Server (systemctl). On my systems, only “root” can issue mount/umount for the “Vault” Partition which contains the critical Backups.

The correct way is to grant the user account that you’re running seafile under sudo access to run the mount command and systemctl.

There’s no reason any of the seafile scripts need to run with unchecked root access.

You could invoke the seaf-gc.sh command to be executed by seafile-user in your “cron” script with:
sudo -u seafile /path/to/seaf-gc.sh

Edit: package sudo needs to be installed for that to work

So much for my ability as a tester: It WORKS! It would be nice if the Seafile Server documentation was updated to reflect this useful little trick. Now, I only need the one “cron” script for “root”. Thank you Bernie_O for the suggestion. CORRECTION: This little trick is also needed for “seaf-fsck.sh” when invoked by a “cron” script running as “root”. Sorry for any confusion I created. END CORRECTION

*Every Monday at 00H05 (you can modify to your liking)

#Seafile Pro Edition
5 0 * * 1 /home/Your seafile folder/seafile-pro-server-*/seaf-gc.sh -t 20 > /home/Your seafile folder/logs/seaf-gc.log

#Seafile Community Edition
5 0 * * 1 /home/Your seafile folder/seafile-server-*/seaf-gc.sh -t 20 > /home/Your seafile folder/logs/seaf-gc.log

You can specify the thread number in with “-t” option. “-t” option can be used together with all other options. Each thread will do GC on one library. For example, the following command will use 20 threads to GC all libraries:

seaf-gc.sh -t 20
https://manual.seafile.com/maintain/seafile_gc.html