服务显示 activating 却一直不进入 active,八成是配置读不到或者权限不对。
先看三样东西
systemctl status foo -l --no-pager
journalctl -u foo -n 50 --no-pager
systemctl show foo -p ExecStart -p User -p Environment
最常见的坑
- 服务以
nobody运行,但配置文件权限是600 root:root,直接读不到 ProtectSystem=strict把日志目录也保护了,写日志失败After=写了但漏了Wants=,依赖服务没起来- Restart 策略太激进导致 systemd 判定为启动失败循环
排查顺序建议:先确认进程能不能以前台方式手动跑起来,再去看 systemd 的差异,比在 unit 文件里猜要快。