首页/系统/信创系统运维速查/systemctl 服务启停与状态查看
服务与运维65 条

systemctl 服务启停与状态查看

systemd 下服务管理的入口命令:start/stop/restart 控制运行状态,status 查看详情,is-active/is-enabled 适合脚本判断,麒麟 V10、UOS、openEuler 通用。

信创系统运维速查系统更新于 2026-10-12
用途服务启停与状态查询
语法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 nginx
restart 会短暂中断服务:数据库、网关类服务先确认业务窗口;服务自身支持时优先用 reload。

易错点

  • reload 与 restart 语义不同:reload 只让进程重读配置,restart 是停止再启动;配置不支持 reload 时会直接报错
  • 脚本里不要混用 service 旧命令与 systemctl 判断,新老接口的返回码不一致,统一 systemctl

数据来源与参考

  • man 1 systemctl(systemd)
  • openEuler 文档:使用 systemd 管理系统服务
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌