From da0832178c3013015e29f2cc029b1048fbee944b Mon Sep 17 00:00:00 2001 From: Troy Lindsay Date: Sun, 19 Jul 2020 10:33:59 -0500 Subject: [PATCH] * [Reference](https://github.com/msmhq/msm/issues/50#issuecomment-7082834) --- cron/msm | 14 +++++++++++++- installers/common.sh | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cron/msm b/cron/msm index 2a31115..d92b64d 100644 --- a/cron/msm +++ b/cron/msm @@ -2,7 +2,7 @@ # Minecraft Server Manager Cron # # Backs up worlds, rolls logs, moves worlds in RAM to disk, -# and starts crashed servers +# starts crashed servers, and deletes old archives # # For more information visit the project home page: # https://github.com/msmhq/msm @@ -20,3 +20,15 @@ # Start any crashed servers again each hour @hourly minecraft /etc/init.d/msm start + +# Deletes all server log files older than the number of days specified in the mtime parameter value +10 05 * * * minecraft find /opt/msm/servers/*/logs -maxdepth 1 -mtime +30 -type f -name "*.log.gz" | xargs rm --force + +# Deletes all server backup files older than the number of days specified in the mtime parameter value +12 05 * * * minecraft find /opt/msm/archives/backups -maxdepth 2 -mtime +30 -type f -name "*.zip" | xargs rm --force + +# Deletes all msm log files older than the number of days specified in the mtime parameter value +14 05 * * * minecraft find /opt/msm/archives/logs -maxdepth 2 -mtime +30 -type f -name "*.log.gz" | xargs rm --force + +# Deletes all server world backup files older than the number of days specified in the mtime parameter value +16 05 * * * minecraft find /opt/msm/archives/worlds -maxdepth 3 -mtime +30 -type f -name "*.zip" | xargs rm --force diff --git a/installers/common.sh b/installers/common.sh index 09797aa..1ca96c5 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -106,7 +106,8 @@ function patch_latest_files() { # patch cron file install_log "Patching MSM cron file" sudo awk '{ if ($0 !~ /^#/) sub(/minecraft/, "'$msm_user'"); print }' \ - "$dl_dir/msm.cron.orig" >"$dl_dir/msm.cron" + "$dl_dir/msm.cron.orig" | \ + sed "s#/opt/msm#$msm_dir#g" >"$dl_dir/msm.cron" # patch init file install_log "Patching MSM init file"