1.将av_streamer -i input_stream.so -o output_app.so 后台重定向到无底洞中去或者是运行在后台中
2.检测程序运行的命令
ps |grep -w av_streamer |grep -v grep|wc -l
监测到运行程序返回1,没有监测到则返回0
3.根据检测到的状态决定是否启动程序
返回0启动程序 av_streamer -i input_stream.so -o output_app.so
返回1打印:程序正在运行。
具体表现在
#!/bin/sh
count=0
while true
do
ProcNumber=`ps |grep -w av_streamer |grep -v grep|wc -l`
if [ 1 -eq $ProcNumber ];then
# echo "task running..."
count=$((count + 1))
echo "task running is" $count
sleep 30s
else
echo "task not run..."
sleep 30s
av_streamer -i input_stream.so -o output_app.so &
echo "task start run..."
fi
done
因篇幅问题不能全部显示,请点此查看更多更全内容