首页 > 代码库 > linux-启动停止重启shell 简单shell示例

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
~

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