shell脚本启动程序,防止重复启动
来源:互联网 发布:易知投资待遇 编辑:程序博客网 时间:2024/06/05 15:54
#!/bin/sh
programdir="."
program="test.py"
export CLASSPATH=$programdir
export LANG=zh_CN
startup()
{
res=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$res" ]
then
echo "$program already running"
else
nohup python $program > startup_out.file 2>&1 &
sleep 3
unset res
res=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$res" ]
then
echo " $program start success"
else
echo "$program start error"
fi
fi
}
shutdown()
{
proc_id=`ps aux|grep python|grep $program|grep -v grep|awk '{print $2}'`
if [ -n "$proc_id" ]
then
echo " $program is start,now kill......"
kill -9 $proc_id
echo " $proc kill ok !!!!!!!!!!!!!"
else
echo " $program is not start!!!!!!!!!!!"
fi
}
case "$1" in
start)
startup
;;
stop)
shutdown
;;
restart)
shutdown
startup
;;
*)
echo "Usage: {start|stop|restart}" >&2
exit 1
;;
esac
exit
- shell脚本启动程序,防止重复启动
- 防止重复启动同一个程序
- 程序启动脚本 shell
- Shell 脚本启动java程序
- shell 脚本启动jar程序
- 启动程序脚本,shell版本
- 防止重复启动应用程序
- 防止重复启动
- 防止软件重复启动
- 防止shell脚本重复执行
- 【shell】防止脚本重复运行
- 一个启动Java程序的shell脚本
- 防止JAVA程序重复启动进程的解决办法
- 防止程序二次启动
- shell启动脚本
- spark shell启动脚本
- linux shell 启动脚本
- redis shell启动脚本
- ffmpeg里的结构关联
- H.264 sequence_parameter_sets成员值含义学习笔记
- 音视频参数解释
- h264 Nalu 详解
- H264 ~~~RTP
- shell脚本启动程序,防止重复启动
- h264 sps pps
- h264 图像宽度与高度的获取
- 微软cortana中文版 新鲜出炉
- 有用的小代码
- 常用正则表达式
- 十六进制字符串转换成中文
- IOS开源项目汇总
- IOS开发中判断文件是否存在,不存在则拷贝[转]