您的位置:首页 > 运维架构 > Shell

shell脚本只运行一个实例

2018-08-29 11:29 459 查看
#

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}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: