linux-启动停止重启shell 简单shell示例

停止:

#!/bin/bash
pid=`ps -ef|grep /opt/lampp|grep -v grep|awk '{print $2}'|wc -l`
b=0
if [ $pid -gt $b ]
then
ps -ef|grep /opt/lampp|grep -v grep|awk '{print $2}'|xargs kill -9
echo "lammp has stopped!"
else
echo "lammp is not running!"
fi
启动:

#!/bin/bash
pid=`ps -ef|grep /opt/lampp|grep -v grep|awk '{print $2}'|wc -l`
b=0
if [ $pid -gt $b ]
then
echo "lammp is already running!"
else
/opt/lampp/lampp start
echo "lammp has started!"
tail -f /opt/lampp/logs/access_log
fi

重启:

/tmp/stopl.sh
/tmp/startl.sh
~

posted @ 2016-09-21 11:45  D.零下的小书屋  阅读(5846)  评论(0编辑  收藏  举报