Update Proxmox/pbs_logrotate.sh
This commit is contained in:
@@ -47,8 +47,8 @@ if [[ -n "$existing_cron" ]]; then
|
||||
fi
|
||||
|
||||
# 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' | uniq | sed '/^$/d' | { cat; echo "$cron_job"; } | crontab -
|
||||
current_crontab=$(crontab -l 2>/dev/null | grep -vF "$cron_job")
|
||||
echo -e "$current_crontab\n$cron_job" | sed '/^$/d' | crontab -
|
||||
|
||||
# Check if the cron job was added successfully
|
||||
if [[ $? -eq 0 ]]; then
|
||||
@@ -61,4 +61,4 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
Reference in New Issue
Block a user