diff --git a/backend/templates_cert/setup-cert.sh.j2 b/backend/templates_cert/setup-cert.sh.j2 index ba241a3..ff784a9 100644 --- a/backend/templates_cert/setup-cert.sh.j2 +++ b/backend/templates_cert/setup-cert.sh.j2 @@ -33,7 +33,10 @@ fi # 3. 写入定时任务 echo "[3/4] 配置定时任务(每小时执行一次)..." CRON_LINE="0 * * * * ${DEPLOY_SCRIPT} >> ${LOG_FILE} 2>&1" -(crontab -l 2>/dev/null | grep -v "${DEPLOY_SCRIPT}"; echo "${CRON_LINE}") | crontab - +EXISTING=$(crontab -l 2>/dev/null || true) +FILTERED=$(echo "${EXISTING}" | grep -v "${DEPLOY_SCRIPT}" || true) +echo "${FILTERED} +${CRON_LINE}" | crontab - echo " 已添加: ${CRON_LINE}" # 4. 验证