Update Scripts/mc-backup.sh

This commit is contained in:
dataprolet 2024-10-13 14:53:22 +02:00
parent e77cb9afce
commit 6d3e1875f9
1 changed files with 5 additions and 4 deletions

View File

@ -64,8 +64,8 @@ for dir in *; do
# Delete all directories except for the most recent one
if [[ ${dir} != ${dir_recent} ]]; then
# Check if directory is older than 1 day
find ${dir} -maxdepth 0 -type d -mtime +1 -exec echo "Backup {} deleted." \; -exec rm -rf {} +
# Check if directory is older than 12 hours
find ${dir} -maxdepth 0 -type d -mmin +720 -exec echo "Backup {} gelöscht." \; -exec rm -rf {} +
fi
fi
done
@ -73,9 +73,10 @@ done
##################################################
## Delete Old Logs
find "/home/$user/.minecraft/" -name 'launcher_log*' -size +1G -mtime +1 -exec rm {} +
# Check if Minecraft and the launcher are not running
if ! pgrep -f "minecraft" > /dev/null; then
if ! pgrep -f "minecraft*.jar" > /dev/null && ! pgrep -f "minecraft-launcher" > /dev/null; then
# Delete official logs that are larger than 1 GB and older than 1 hour
find "/home/$user/.minecraft/" -name 'launcher_log*' -size +1G -mmin +60 -exec rm {} +