mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-27 23:08:14 +03:00
Cron job fixes
- Previously, changes in CRON_TIME will apply but the previous CRON_TIME will not be removed. - Jobs are now cleared when ran every time. - Backup and delete scripts are now added when ran every time. - An echo is added to signify that parameters, changed or not, are acknowledged and applied.
This commit is contained in:
parent
d47892e8bf
commit
fe9ab8e045
@ -11,15 +11,18 @@ if [ "$1" = "manual" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create cron jobs.
|
||||
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
|
||||
# Create cron jobs if root.
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
# Clear cron jobs.
|
||||
echo "" | crontab -
|
||||
echo "[INFO] Cron jobs cleared."
|
||||
|
||||
# Add backup script to cron jobs.
|
||||
(crontab -l 2>/dev/null; echo "$CRON_TIME $BACKUP_CMD >> $LOGS_FILE 2>&1") | crontab -
|
||||
echo "[INFO] Added backup script to cron jobs."
|
||||
|
||||
# Check if $DELETE_AFTER is not null and is greater than 0.
|
||||
# If so, add it to cron jobs.
|
||||
if [ -n "$DELETE_AFTER" ] && [[ "$DELETE_AFTER" -gt 0 ]]; then
|
||||
# Add delete script to cron jobs if DELETE_AFTER is not null and is greater than 0.
|
||||
if [ -n "$DELETE_AFTER" ] && [ "$DELETE_AFTER" -gt 0 ]; then
|
||||
(crontab -l 2>/dev/null; echo "$CRON_TIME $DELETE_CMD >> $LOGS_FILE 2>&1") | crontab -
|
||||
echo "[INFO] Added delete script to cron jobs."
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user