diff --git a/Proxmox/pbs_logrotate.sh b/Proxmox/pbs_logrotate.sh index bb9ddcd..020e33e 100644 --- a/Proxmox/pbs_logrotate.sh +++ b/Proxmox/pbs_logrotate.sh @@ -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