#>vi runonce
#/bin/bash
##判断有同名shell是否正在执行
PG=`basename {GetProperty(Content)}`
PN=`ps -ef | grep "$PG"| grep -v "grep" | awk 'BEGIN {a=0;} {a++;} END{print(a)}'`
#如果没有重复实例,正常执行
if [ $PN -le 0 ]
then
echo startup now!
if [ -x {GetProperty(Content)} ]; then
. {GetProperty(Content)}
else
echo excute access deny: {GetProperty(Content)}
fi
#如果已经有个实例在运行,退出本实例
else
echo already startup!
exit 1;
fi
调用runonce a.sh
本文作者:
#>vi runonce
#/bin/bash
##判断有同名shell是否正在执行
PG=`basename {GetProperty(Content)}`
PN=`ps -ef | grep "$PG"| grep -v "grep" | awk 'BEGIN {a=0;} {a++;} END{print(a)}'`
#如果没有重复实例,正常执行
if [ $PN -le 0 ]
then
echo startup now!
if [ -x {GetProperty(Content)} ]; then
. {GetProperty(Content)}
else
echo excute access deny: {GetProperty(Content)}
fi
#如果已经有个实例在运行,退出本实例
else
echo already startup!
exit 1;
fi
调用runonce a.sh
本文作者: