| 用途 | 服务启停与状态查询 |
|---|---|
| 语法 | systemctl [子命令] [单元] |
| 适配 | Kylin V10 / UOS / openEuler 同为 systemd 体系 |
常用操作
常用操作
systemctl start nginx # 启动
systemctl stop nginx # 停止
systemctl restart nginx # 重启(会断开现有连接)
systemctl reload nginx # 重载配置(不断连接,需服务自身支持)
systemctl status nginx # 状态与最近日志
systemctl is-active nginx; systemctl is-enabled nginx脚本中的判断写法
脚本中的判断写法
systemctl is-active --quiet nginx || systemctl start nginx
systemctl is-enabled nginxrestart 会短暂中断服务:数据库、网关类服务先确认业务窗口;服务自身支持时优先用 reload。