当前位置: 技术问答>linux和unix
大侠们帮我解释下这个.sh文件中的命令
来源: 互联网 发布时间:2017-01-23
本文导语: 本帖最后由 f504501983 于 2011-12-09 11:47:12 编辑 #!/bin/bash #cd /home/sis/EnvDataCenterCollection exename=Enserver.jar pid=`ps ax|grep ${exename}|grep -v grep|awk '{print $1}'` if [[ $pid ]] then echo 'find pid is '$pid kill -9 $pid echo "killed $pid o...
#cd /home/sis/EnvDataCenterCollection
exename=Enserver.jar
pid=`ps ax|grep ${exename}|grep -v grep|awk '{print $1}'`
if [[ $pid ]]
then
echo 'find pid is '$pid
kill -9 $pid
echo "killed $pid over"
else
echo "There is no process running....."
fi
echo "start new process...."
nohup java -jar ${exename}>>./nohup.out 2>&1 &
ps -ef |grep '${exename}'|grep -v grep
echo 'restart successfully'
没怎么接触过linux命令。请大侠们帮我解释解释。
|
#!/bin/bash
#cd /home/sis/EnvDataCenterCollection
exename=Enserver.jar 变量,把Enserver.jar赋值给exename
pid=`ps ax|grep ${exename}|grep -v grep|awk '{print $1}'` 得到包含Enserver.jar的进程的pid
if [[ $pid ]]
then
echo 'find pid is '$pid
kill -9 $pid 存在包含Enserver.jar的进程的pid就把这个进程杀死
echo "killed $pid over"
else
echo "There is no process running....."
fi
echo "start new process...."
nohup java -jar ${exename}>>./nohup.out 2>&1 & 开始新的进程,后台运行,
ps -ef |grep '${exename}'|grep -v grep 进程是否存活,即查看新进程是否开启
echo 'restart successfully'
上面那段shell就是用于重启Enserver.jar这个应用的
#cd /home/sis/EnvDataCenterCollection
exename=Enserver.jar 变量,把Enserver.jar赋值给exename
pid=`ps ax|grep ${exename}|grep -v grep|awk '{print $1}'` 得到包含Enserver.jar的进程的pid
if [[ $pid ]]
then
echo 'find pid is '$pid
kill -9 $pid 存在包含Enserver.jar的进程的pid就把这个进程杀死
echo "killed $pid over"
else
echo "There is no process running....."
fi
echo "start new process...."
nohup java -jar ${exename}>>./nohup.out 2>&1 & 开始新的进程,后台运行,
ps -ef |grep '${exename}'|grep -v grep 进程是否存活,即查看新进程是否开启
echo 'restart successfully'
上面那段shell就是用于重启Enserver.jar这个应用的