Update Proxmox/pbs_logrotate.sh
This commit is contained in:
@@ -36,7 +36,7 @@ fi
|
|||||||
log_directory="/var/log/proxmox-backup"
|
log_directory="/var/log/proxmox-backup"
|
||||||
backup_directory="/var/log/proxmox-backup-backup"
|
backup_directory="/var/log/proxmox-backup-backup"
|
||||||
mkdir -p "$backup_directory"
|
mkdir -p "$backup_directory"
|
||||||
cron_command="find $log_directory -mtime +$days_to_keep -type f -exec mv {} $backup_directory/ \; && find $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/fin $backup_directory -mtime +30 -type f -exec rm {} +"
|
||||||
cron_job="0 3 * * * $cron_command"
|
cron_job="0 3 * * * $cron_command"
|
||||||
|
|
||||||
# Check if the cron job already exists
|
# Check if the cron job already exists
|
||||||
@@ -46,8 +46,9 @@ if [[ -n "$existing_cron" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the cron job to the user's crontab
|
# Preserve existing crontab and add the new job
|
||||||
(crontab -l 2>/dev/null; echo "$cron_job") | crontab -
|
current_crontab=$(crontab -l 2>/dev/null)
|
||||||
|
echo -e "$current_crontab\n$cron_job" | awk 'NF' | sort -u | crontab -
|
||||||
|
|
||||||
# Check if the cron job was added successfully
|
# Check if the cron job was added successfully
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user