Check if cron entry for garbage collection already exists

This commit is contained in:
Gerrit Gogel 2023-06-19 02:57:13 +02:00 committed by GitHub
parent 45a585d945
commit ff1c91c6d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,7 +34,11 @@ function stop_socat {
function gc_cron {
if [[ ! -z $GC_CRON ]]; then
echo "Scheduling garbage collection..."
if ! crontab -l | grep -Fxq "$GC_CRON /scripts/gc.sh >> /opt/seafile/logs/gc.log 2>&1"; then
(crontab -l ; echo "$GC_CRON /scripts/gc.sh >> /opt/seafile/logs/gc.log 2>&1") | crontab
fi
service cron start
fi
}