From 2265c48a5306d5079671866ddc6ce6c2565ca40a Mon Sep 17 00:00:00 2001 From: yml2213 Date: Mon, 17 Aug 2026 00:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=87=E4=BB=BD=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E9=80=80=E5=87=BA=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/backup-scheduler.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/backup-scheduler.sh b/scripts/backup-scheduler.sh index bdb168d..a803761 100755 --- a/scripts/backup-scheduler.sh +++ b/scripts/backup-scheduler.sh @@ -35,11 +35,13 @@ run_job() { write_job_state "${status_dir}" "${type}" success '执行成功' "${SCRIPT_DIR}/backup-status.sh" write || true return + else + # 必须在失败分支中立即读取退出码;if 语句本身在无 else 时会返回 0。 + local code=$? + write_job_state "${status_dir}" "${type}" failed "执行失败(退出码 ${code})" + "${SCRIPT_DIR}/backup-status.sh" write || true + return "${code}" fi - local code=$? - write_job_state "${status_dir}" "${type}" failed "执行失败(退出码 ${code})" - "${SCRIPT_DIR}/backup-status.sh" write || true - return "${code}" } main() {