#!/bin/bash
#$$表示当前shell的pid号,需要过滤掉(防止当前shell脚本名字包含nginx的字符)
ps -ef|grep nginx|grep -vE "grep|$$" >/dev/null
#直接通过$?获取上一句shell执行的状态
if [ $? -eq 0 ];thenecho"Nginx is running"else
systemctl start nginx
echo"Nginx is down,Starting..."fi
原文:https://www.cnblogs.com/bretzhao/p/11826464.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!