目的:linux 下服务器程序会因为各种原因dump掉,就会影响用户使用,这里提供一个简单的进程监控和重启功能. 实现原理:由定时任务crontab调用脚本,脚本用ps检查进程是否存在,如果不存在则重启并写入日志. 1.crontab修改 # crontab -e */ * * * * /mnt/bindmonitor.sh 2./mnt/bindmonitor.sh 的实现 #! /bin/sh host_dir=`echo ~` # 当前用户根目录 proc_name="/home/wkub…
目的:linux 下服务器程序会因为各种原因dump掉,就会影响用户使用,这里提供一个简单的进程监控和重启功能. 实现原理:由定时任务crontab调用脚本,脚本用ps检查进程是否存在,如果不存在则重启并写入日志. 1.crontab修改 chen@IED_40_125_sles10sp1:~/CandyAT/Bin> crontab -e */1 * * * * /home/chen/CandyAT/Bin/monitor.sh 上面的意思是每分钟调用一下脚本monitor.sh 2.moni…
/opt/a.sh #! /bin/bash ps -ef | grep python3 a.py | grep -v grep | grep python3 if [ $? -ne 0 ] then cd /opt/a.py && python3 a.py else echo "running" fi 之后写一个定时脚本2分钟捕捉一次 2 * * * * /opt/a.sh…
linux 进程监控 supervise Supervise是daemontools的一个工具,可以用来监控管理unix下的应用程序运行情况,在应用程序出现异常时,supervise可以重新启动指定程序. 使用: mkdir test cd test vim run 写入希望执行的操作 supervise test (注意这里是的参数是run文件上层的文件夹,改变run的为可执行 chmod +x run) monit      monit是一个小型的开放源码工具来管理和监控Unix系统.Mon…
tomcat监控,自动重启shell脚本如下,取名 monitor_tomcat.sh: #!/bin/sh # func:自动监控tomcat脚本并且执行重启操作 # 获取tomcat进程ID(其中[grep -w '.....']中的.....需要替换为实际部署的tomcat文件夹名,如下) TomcatID=$(ps -ef |grep tomcat |grep -w '/usr/local/tomcat/apache-tomcat-8.5.31'|grep -v 'grep'|awk '…
C# 通过代码 Process.Kill 方法杀死桌面进程后,会自动重启 其实可以通过 Taskkill 指令结束桌面进程, 在命令行查看 taskkill 帮助, TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F] 描述: 使用该工具按照进程 ID (PID) 或映像名称终止任务. 参数列表: /S system 指定要连接的…
编辑Crontab crontab -e 按i进行编辑 */ * * * * /root/monitor.sh # 每分钟运行一遍monitor.sh脚本 * * * /sbin/reboot # 每天凌晨5点自动重启服务器 */ * * * * /root/monitor.sh # 每分钟运行一遍monitor.sh脚本 * * * /sbin/reboot # 每天凌晨5点自动重启服务器 重启服务 systemctl restart crond monitor.sh #!/bin/sh ec…
设计思想:编写批处理脚本监控进程的运行状态,如果发现进程停止,则自动重启该进程.批处理脚本(jk.bat)和进程脚本(hello.bat)如下: 1.jk.bat @echo off rem 定义需监控程序的进程名和程序路径,可根据需要进行修改 set AppName=myHello.jar set AppPath=C:\Users\dongbr\Desktop\test\ title 进程监控 cls echo. echo 进程监控开始…… echo. rem 定义循环体 :startjc r…
脚本文件 该脚本实现了一个检测进程是否存在,不存在的情况下重启进程并且记录日志. #! /bin/sh proc_name="console/queue/gift.php" # 进程名 log_name="/data/log/watch_queue.log" # 日志文件 pid=0 proc_num() # 计算进程数 { num=`ps -ef | grep $proc_name | grep -v grep | wc -l` return $num } pro…
1 创建循环监听脚本  autostart.sh 例: 其中futures-market-server-v3andwebsoket.jar 是要监听的执行程序 #/bin/bashwhile true;do count=`ps -ef | futures-market-server-v3andwebsoket.jar | grep -v grep|wc -l` if [ ${count} -lt 1 ]; then /./home/quant/futures/jar/futures-market…