diff --git a/Config/Automation/backup.sh b/Config/Automation/backup.sh index 3cfa4a3..df5c06c 100644 --- a/Config/Automation/backup.sh +++ b/Config/Automation/backup.sh @@ -109,7 +109,8 @@ EOF chmod +x "$path/backup.sh" declare cron_job="${cron} ${path}/backup.sh" -(crontab -l 2>/dev/null | grep -Fxq "${path}/backup.sh") || (crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab - +(crontab -l 2>/dev/null | grep -v "backup.sh") | sudo crontab - +(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab - sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败" diff --git a/Config/Automation/update.sh b/Config/Automation/update.sh index 75fc88b..1bc9ab8 100644 --- a/Config/Automation/update.sh +++ b/Config/Automation/update.sh @@ -22,4 +22,9 @@ EOF esac chmod +x "${path}/update.sh" + +declare cron_job="${cron} ${path}/update.sh" +(crontab -l 2>/dev/null | grep -v "update.sh") | sudo crontab - +(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab - + sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败" \ No newline at end of file diff --git a/Menus/Automation.sh b/Menus/Automation.sh index e59314b..1d1ff84 100644 --- a/Menus/Automation.sh +++ b/Menus/Automation.sh @@ -53,6 +53,11 @@ for dir in "\$web_path"/*/; do done EOF chmod +x "${path}/up-docker_compose.sh" + + declare cron_job="${cron} ${path}/up-docker_compose.sh" + (crontab -l 2>/dev/null | grep -v "up-docker_compose.sh") | sudo crontab - + (crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab - + sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败" ;; '4')