[工具]进程守护脚本
来源:互联网 发布:Buffer cache linux 编辑:程序博客网 时间:2024/05/21 09:04
#!/bin/bash
##Daemon Script##
##Please put this Script in the Program Directory##
##Create by zph##
SleepTime=10
ProcUser=appadmin
ProcMaster=java
ProgramBase=/opt
ProcProgram=startup.sh
if [ `dirname $0` = '.' ];then
ProcName=`pwd|xargs basename`
else
ProcName=`dirname $0|xargs basename`
fi
DaemonLog=${ProcName}_Daemon.log
if [ ! -f $DaemonLog ];then
touch $DaemonLog
fi
while true;do
ProcStatus=`ps -ef |grep $ProcMaster|grep "$ProgramBase/$ProcName"|grep -v grep|wc -l`
if [ `whoami` != $ProcUser ];then
UserStat="su - $ProcUser -c "
else
UserStat=""
fi
if [ $ProcStatus = 0 ];then
source /etc/profile
$UserStat $ProgramBase/$ProcName/bin/$ProcProgram >/dev/null 2>&1
echo "$(date +%Y-%m-%d_%H:%M:%S)Process is Down!!!Now Restart!" >>$DaemonLog
#else
#echo "$(date +%Y-%m-%d_%H:%M:%S)Process is Running!!!">>$DaemonLog
fi
sleep $SleepTime
done
##Daemon Script##
##Please put this Script in the Program Directory##
##Create by zph##
SleepTime=10
ProcUser=appadmin
ProcMaster=java
ProgramBase=/opt
ProcProgram=startup.sh
if [ `dirname $0` = '.' ];then
ProcName=`pwd|xargs basename`
else
ProcName=`dirname $0|xargs basename`
fi
DaemonLog=${ProcName}_Daemon.log
if [ ! -f $DaemonLog ];then
touch $DaemonLog
fi
while true;do
ProcStatus=`ps -ef |grep $ProcMaster|grep "$ProgramBase/$ProcName"|grep -v grep|wc -l`
if [ `whoami` != $ProcUser ];then
UserStat="su - $ProcUser -c "
else
UserStat=""
fi
if [ $ProcStatus = 0 ];then
source /etc/profile
$UserStat $ProgramBase/$ProcName/bin/$ProcProgram >/dev/null 2>&1
echo "$(date +%Y-%m-%d_%H:%M:%S)Process is Down!!!Now Restart!" >>$DaemonLog
#else
#echo "$(date +%Y-%m-%d_%H:%M:%S)Process is Running!!!">>$DaemonLog
fi
sleep $SleepTime
done
0 0
- [工具]进程守护脚本
- 守护进程脚本
- 守护进程监测脚本
- Codis进程守护脚本
- linux守护进程脚本
- 进程守护工具Supervisor
- shell脚本设置守护进程
- php脚本守护进程设计
- Linux守护进程Shell脚本
- Linux守护进程Shell脚本
- shell 脚本实现的守护进程
- shell 脚本实现的守护进程
- shell 脚本实现的守护进程
- 用shell 脚本写守护进程
- shell 脚本实现的守护进程
- 一个守护vsftp进程的脚本
- 一个简单的脚本守护进程
- 用shell 脚本写守护进程
- 密码学扫盲:加密、认证、公钥、私钥
- CentOs 安装配置Jboss
- Error:OnClickListener cannot be resolved to a type
- nginScript
- 推荐一个在线编辑Latex公式的网站
- [工具]进程守护脚本
- Linux 设备节点
- 编程技巧 - 8
- 常用目录名
- 欢迎使用CSDN-markdown编辑器
- AA记账随手记ios项目源码
- 实例变量那点事
- css毛玻璃效果
- Codeforces Round #299 (Div. 1) A. Tavas and Karafs(二分)