定时检查进程的shell脚本
来源:互联网 发布:mac怎么卸载搜狗 编辑:程序博客网 时间:2024/06/11 10:52
#!/bin/bash
#TIME=18:32
#while [ 1 -eq 1 ]
#do
#TMP=`date +'%H:%M'`
#echo $TMP $TIME
#if [ "$TMP" = "$TIME" ]
#then
#echo "时间到了,开始执行程序"
#break
#fi
#sleep 1
#done
lryDir=/settle1/card2/script/lry
echo "每隔5分钟检查一次进程"
lrynow=`date +%Y%m%d`
if [ -f $lryDir/Log/log_check_$lrynow ]
then
echo "文件已经存在,采用追加方式"
>> $lryDir/Log/log_check_$lrynow
echo "`date +%T` :文件已经存在,采用追加方式" | tee -a $lryDir/Log/log_check_$lrynow
else
> $lryDir/Log/log_check_$lrynow
echo "`date +%T` :新建日志文件log_check_$lrynow" | tee -a $lryDir/Log/log_check_$lrynow
fi
echo "每隔5分钟检查一次进程" |tee -a $lryDir/Log/log_check_$lrynow
TIME=0900
checkcard_ps()
{
checkps=$1
if [ $checkps = Standserver ]
then
echo "`date +%T` : 当前进程为:$checkps"
fi
status=`pscard | grep $checkps | wc -l`
#echo $status
if [ $status == 0 ]
then
echo "`date +%T`的时候:$checkps进程挂掉了,准备运行$checkps" | tee -a $lryDir/Log/log_check_$lrynow
cd /settle1/card2/bin
nohup $checkps &
echo $?
if [ $? -eq 0 ]
then
echo "`date +%T`时候:程序$checkps启动成功" | tee -a $lryDir/Log/log_check_$lrynow
sleep 60
if [ $checkps = Standserver ]
then
echo "!!!!!!`date +%T`时候:准备修改配置文件" | tee -a $lryDir/Log/log_check_$lrynow
cat /settle1/card2/script/lry/lryconfig > /settle1/card2/bin/config.ini
echo "!!!!!!`date +%T`时候:配置文件修改完毕" | tee -a $lryDir/Log/log_check_$lrynow
fi
fi
sleep 5
else
echo "`date +%T` : $checkps正常运行"
sleep 1
fi
}
echo "`date +%T` : $lrynow开始执行检查进程程序" | tee -a $lryDir/Log/log_check_$lrynow
while [ 1 -eq 1 ]
do
TMP=`date +'%H%M'`
for lryps in SettleAgent Standserver Cardcollect Statserver Import Billserver osagent Msgserver
do
echo "$lryps"
checkcard_ps $lryps
done
echo "`date +%T` : 检查完毕"
echo $TMP
echo $TIME
if [ "$TMP" -gt "$TIME" ]
then
echo "`date +%T` : 时间到了,退出程序" | tee -a $lryDir/Log/log_check_$lrynow
break
fi
sleep 291
done
- 定时检查进程的shell脚本
- 定时检查进程的shell脚本
- shell脚本检查进程是否启动
- Shell脚本检查memcache进程并自动重启
- 用Shell脚本定时监控Linux下的进程状态并自动重启
- 检查字段并排序的shell脚本
- 检查系统状态的一段shell脚本
- Shell脚本的静态检查工具shellcheck
- 监控进程的shell脚本
- 定时任务中shell脚本的执行
- [shell]避免定时任务脚本的常见问题
- Linux定时shell脚本
- Shell写的一个进程监视脚本
- 用于检测进程的shell脚本
- 好用的shell脚本 控制进程
- shell 脚本实现的守护进程
- Shell脚本实现进程的自动拉起
- shell 脚本实现的守护进程
- 搞定一个在DataGrid中DropDownList模板列值初始化的问题
- C++调用VBS
- Z buffer 和 W buffer
- DataGrid中DropDownList的动态绑定和触发DropDownList事件
- Windows Identity Foundation(WIF)正式发布
- 定时检查进程的shell脚本
- guihua
- 关注未来,迎接wave--(2)
- Exception starting filter struts2 Caught exception while loading file struts-default.xml - [unknown location]
- 每日心程
- DIY发烧友们如何选择“兼容”电源
- 扒一扒几个“另类”的互联网服务
- 扒一扒近几年少有的经典软件
- 2010年薪水降幅最大的16大IT职位排名