shell和bat 监控进程,自动关机
1.linux 下监控进程,进程结束后关机
新建文件 monit.sh
$chmod +x monit.sh
加入代码
#!/bin/sh a=; while [ $a -gt ]; do if test $(pgrep -f $|wc -l) -eq ;then echo "shutdown after 2 mins.."
shutdown -h else
echo "$1 still running"
fi;
sleep ;
done;
2.window下监控进程,结束关机
新建文本 monit.bat
贴代码:
:start
tasklist >tasklist.txt
find /i tasklist.txt "vmware-vmx.exe"
if errorlevel ((del /q tasklist.txt)&(goto end))
if errorlevel (
echo "running"
ping 127.1 -n >nul >nul
(goto start))
:end
echo "shutdown after 60s"
ping 127.1 -n >nul >nul
shutdown -s -t
这个也可以
@echo off
:
tasklist | find "YodaoDict1exe" >>c:\notepad.luowei
if exist c:\notepad.luowei (
::taskkill /f /im YodaoDict.exe
echo running
ping 127.1 -n >nul >nul
) else (
echo 200s后关机
ping 127.1 -n >nul >nul
shutdown -s -t
)
goto
shell和bat 监控进程,自动关机的更多相关文章
- 用shell脚本监控进程是否存在 不存在则启动的实例
用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]th ...
- linux shell脚本监控进程是否存在
用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ...
- python 守护进程,监控进程
守护进程代码: import time, os import subprocess def run(): while True: taskList = os.popen('tasklist').rea ...
- shell脚本实现监控shell脚本的执行流程及变量的值
这篇文章主要介绍了shell脚本实现监控shell脚本的执行流程及变量的值本文使用shell完成对执行过程中条件语句中的变量的变化的监控和整个程序的执行流程的观察功能,需要的朋友可以参考下 很多时候, ...
- python os.startfile python实现双击运行程序 python监控windows程序 监控进程不在时重新启动
用python监控您的window服务 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://world77.blog.51cto.co ...
- linux 下监控进程流量情况命令 NetHogs
摘自: http://www.cnblogs.com/kerrycode/p/4748970.html NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linu ...
- 使用supervisor监控进程
在linux下监控进程,可以使用inittab,最近找到了supervisor,也很好用,记录一下:1.系统要安装python,并安装与之对应的setuptools,下载地址在此2.安装:# sh s ...
- SNMP远程监控进程信息的OID
最近有个项目需要用snmp远程监控进程信息.于是我查了一下资料. 一.资料 .1.3.6.1.2.1.25.4.2.1.1.iso.org.dod.internet.mgmt.mib-2.host.h ...
- MHA监控进程异常退出
这两天遇到一个非常诡异的问题,打算和大家分享一下.只所以诡异估计是自己知识面不够吧.线上的MHA一直没有开启自动切换,都是手动切换的,最近开启了自动切换以后,退出securecrt窗口以后发现监控进程 ...
随机推荐
- Extjs控制面板组件
(1)aoolyTo:(id) renderTo:(id)呈现在哪个html里面,同上 id最好用"" contentEI:() 呈现哪个html元素里面,把eI内的内容呈现 ( ...
- JSP知识点汇总
有几种方法可以实现服务器内部跳转? 使用request对象提供的方法:request.getRequestDispatcher(String URI).forward(ServletRequest r ...
- kibana ,logstash and filebeat
https://www.elastic.co/guide/en/kibana/current/install.html https://www.elastic.co/guide/en/logstash ...
- Vue知识点
1. Vue生命周期图示: 2.插值: 文本:{{ message }}: 纯html:v-html="xxx"; 属性:v-bind:id="xxx"; 使用 ...
- Python-基础-时间日期处理小结
Python-基础-时间日期处理小结 涉及对象 1. datetime 2. timestamp 3. time tuple 4. string 5. date datetime基本操作 1. 获取当 ...
- Angular2.0-组件
截止到目前为止,Angular2.0完成了其alpha-32版本的开发,新的版本还在迭代开发当中,这其中有个问题,就是每个版本相比于以前的版本都会有一些改动,包括API方面的修改,这会导致很多基于以前 ...
- 关于初次使用Verilog HDL语言需要懂的基本语法
关于初次使用Verilog HDL语言需要懂的基本语法 1.常量 数字表达式全面的描述方式为:<位宽><进制><数字> 8’b10101100,表示位宽为8的二进制 ...
- 无线路由器WDS简要
A,B两台无线路由器,B去桥接A.在B中保持A相同的无线信道.在B中关闭DHCP.--A,B两台的SSID和无线安全设置都是独立的,无线安全可同可不同.
- web.xml 文件配置01
web.xml 文件配置01 前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...
- Android String操作
android String.valueOf(ch).getBytes("GBK") --------------------------------------------- S ...