Update Proxmox/pbs_logrotate.sh

This commit is contained in:
2025-01-26 08:47:13 +00:00
parent 2245ec7005
commit 582599ec2f

View File

@@ -36,7 +36,7 @@ fi
log_directory="/var/log/proxmox-backup"
backup_directory="/var/log/proxmox-backup-backup"
mkdir -p "$backup_directory"
cron_command="/usr/bin/find $log_directory -mtime +$days_to_keep -type f -exec mv {} $backup_directory/ \; && /usr/bin/fin $backup_directory -mtime +30 -type f -exec rm {} +"
cron_command="/usr/bin/find $log_directory -mtime +$days_to_keep -type f -exec mv {} $backup_directory/ \; && /usr/bin/find $backup_directory -mtime +30 -type f -exec rm {} +"
cron_job="0 3 * * * $cron_command"
# Check if the cron job already exists
@@ -46,9 +46,9 @@ if [[ -n "$existing_cron" ]]; then
exit 0
fi
# Preserve existing crontab and add the new job
# Preserve existing crontab and add the new job at the bottom
current_crontab=$(crontab -l 2>/dev/null)
echo -e "$current_crontab\n$cron_job" | awk 'NF' | sort -u | crontab -
echo -e "$current_crontab\n$cron_job" | awk 'NF' | uniq | sed '/^$/d' | { cat; echo "$cron_job"; } | crontab -
# Check if the cron job was added successfully
if [[ $? -eq 0 ]]; then