shell脚本只运行一个实例

原创
2018/08/29 11:29
阅读数 402
#

PID_FILE=/tmp/$0.pid

#!!!!!!!!!!!!check previous instance 
if [ -e ${PID_FILE} ] 
then
    echo "the previous instance has exist.";
    exit 0;
fi
#
echo $$ > ${PID_FILE}
trap "rm -rf ${PID_FILE}; exit 0" HUP INT QUIT FPE KILL TERM

# ----------------------put your command here ---------------------------------------

for ((i=0; i < 100; i++))
do
python recm.py \
    ../test/mp4 \
    'http://192.168.1.252:8088'

sleep 60
done

#------------------------------------------------------------------------------------

# !!!!!!!!!!!do not remove this command
rm -rf ${PID_FILE}

 

展开阅读全文
打赏
0
1 收藏
分享
加载中
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部