1. 程式人生 > >Linux – 自啟動程式指令碼

Linux – 自啟動程式指令碼

# Monitor Collector is running
# 此指令碼是檢測另外一個程式是否正在執行,如果沒有執行則啟動該程式

Path='PortableCollector'

while test "1"="1";do
	Result=`pgrep $Path`
	if [ ! $Result];then
                # 啟動程式
		/home/default/Collector/PortableCollector -qws  
		echo "Not Running"
		echo $Result
	else
		echo "Running"
		echo $Result
	fi
        # 每次休眠1s
	sleep 1
done