Skip to content

Instantly share code, notes, and snippets.

@RobertWang
Created July 31, 2014 02:20
Show Gist options
  • Save RobertWang/474f6622c846c373fdb0 to your computer and use it in GitHub Desktop.
Save RobertWang/474f6622c846c373fdb0 to your computer and use it in GitHub Desktop.
[sh]判断一个进程是否启动
ps_check () {
psname="$1"
#pslist=`ps aux | grep $psname`
pscount=`ps aux | grep $psname | wc -l`
pscount=`expr $pscount`
if [ "$pscount" -gt 1 ]
then
echo $psname" is running ... [Success]"
else
echo $psname" is not run ... [Fail]"
fi
}
psname="nginx"
ps_check "nginx"
#ps_check $psname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment