systemctl status app
systemctl start app
systemctl stop app
systemctl restart app
systemctl reload app
systemctl enable app
systemctl disable app
systemctl enable --now app
systemctl is-active app
systemctl is-enabled app
systemctl daemon-reload
systemctl list-units --failed
systemctl list-unit-files
systemctl cat app
systemctl edit app
systemctl show app
journalctl -u app -f
journalctl -u app --since '1 hour ago'
journalctl -p err -b
systemd-analyze blame
systemd-analyze critical-chain
| 目的 | 命令 |
|---|---|
| 查看依赖 | systemctl list-dependencies app |
| 查看定时器 | systemctl list-timers |
| 查看 target | systemctl get-default / set-default |
| 重载单个 unit | systemctl reload-or-restart app |
| 临时屏蔽 | systemctl mask app / unmask app |
| 查看日志占用 | journalctl --disk-usage |
| 清理日志 | journalctl --vacuum-size=500M |
| 启动耗时 | systemd-analyze blame |
daemon-reload,否则仍用旧配置。enable 不等于 start;只 start 不会开机自启。Type=simple/forking/notify 选错会导致状态误判。ExecStart 要用绝对路径,环境变量和 WorkingDirectory 显式配置。Restart=always 可能掩盖启动失败;先看日志再决定。journalctl 的持久化取决于 Storage= 配置,重启后可能丢失。合上页面,先回答,再展开对照。
daemon-reload?systemctl enable 和 systemctl start 有什么区别?journalctl 的日志在重启后可能丢失?enable 只设置开机自启,不等于启动服务;只 start 则不会开机自启。enable --now 可以同时完成两者。Storage= 配置,未配置持久化时重启后可能丢失。
小程序版
微信扫码,随时查命令