fix: match crontab entries by script filename (underscore) not task name (hyphen)
This commit is contained in:
@@ -832,9 +832,13 @@ def api_monitor():
|
||||
else:
|
||||
result["tier2"] = {"status": "no_data", "note": f"{t2_file} 不存在", "summary": {"ok": 0, "total": 0}}
|
||||
# 定时任务状态
|
||||
expected_tasks = ["agents-health-check", "agents-daily-health", "agents-todo-executor"]
|
||||
expected_tasks = [
|
||||
("agents-health-check", "agents_health_check.py"),
|
||||
("agents-daily-health", "agents_daily_health.py"),
|
||||
("agents-todo-executor", "self_todo_executor.py"),
|
||||
]
|
||||
if sys.platform == "win32":
|
||||
for name in expected_tasks:
|
||||
for name, filename in expected_tasks:
|
||||
try:
|
||||
r = subprocess.run(["schtasks", "/Query", "/TN", name, "/FO", "CSV", "/NH"],
|
||||
capture_output=True, text=True, timeout=5,
|
||||
@@ -845,10 +849,10 @@ def api_monitor():
|
||||
result["tasks"].append({"name": name, "status": status})
|
||||
else:
|
||||
# Linux: 直接检查本地 crontab(不在 Windows 上跑了)
|
||||
for name in expected_tasks:
|
||||
for name, filename in expected_tasks:
|
||||
try:
|
||||
r = subprocess.run(["crontab", "-l"], capture_output=True, text=True, timeout=5)
|
||||
if name in r.stdout:
|
||||
if filename in r.stdout:
|
||||
result["tasks"].append({"name": name, "status": "cron_ok"})
|
||||
else:
|
||||
result["tasks"].append({"name": name, "status": "not_deployed"})
|
||||
|
||||
Reference in New Issue
Block a user