systemctl status nginx
检查 Nginx 服务运行状态
语法
systemctl status nginx [--no-pager] [--full]说明
适用于 systemd 管理的 nginx.service。status 展示活动状态、主进程 PID 和最近日志摘要;is-active 适合脚本只检查是否运行。active 仅说明服务状态,不保证站点响应或上游业务健康。
参数
--no-pager不进入分页器
--full不截断显示内容
示例
查看详细状态
一次性输出状态和日志摘要。
systemctl status nginx --no-pager --full注意事项:服务未启动时返回非零退出码属于预期结果,日志可见性取决于当前用户权限。
只检查是否活动
用于脚本中的健康检查前置判断。
systemctl is-active nginx注意事项:还应通过 HTTP 请求验证站点功能,不能只依赖进程状态。