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 监控进程,自动关机的更多相关文章

  1. 用shell脚本监控进程是否存在 不存在则启动的实例

    用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]th ...

  2. linux shell脚本监控进程是否存在

    用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货:    #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ...

  3. python 守护进程,监控进程

    守护进程代码: import time, os import subprocess def run(): while True: taskList = os.popen('tasklist').rea ...

  4. shell脚本实现监控shell脚本的执行流程及变量的值

    这篇文章主要介绍了shell脚本实现监控shell脚本的执行流程及变量的值本文使用shell完成对执行过程中条件语句中的变量的变化的监控和整个程序的执行流程的观察功能,需要的朋友可以参考下 很多时候, ...

  5. python os.startfile python实现双击运行程序 python监控windows程序 监控进程不在时重新启动

    用python监控您的window服务 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://world77.blog.51cto.co ...

  6. linux 下监控进程流量情况命令 NetHogs

    摘自: http://www.cnblogs.com/kerrycode/p/4748970.html NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linu ...

  7. 使用supervisor监控进程

    在linux下监控进程,可以使用inittab,最近找到了supervisor,也很好用,记录一下:1.系统要安装python,并安装与之对应的setuptools,下载地址在此2.安装:# sh s ...

  8. SNMP远程监控进程信息的OID

    最近有个项目需要用snmp远程监控进程信息.于是我查了一下资料. 一.资料 .1.3.6.1.2.1.25.4.2.1.1.iso.org.dod.internet.mgmt.mib-2.host.h ...

  9. MHA监控进程异常退出

    这两天遇到一个非常诡异的问题,打算和大家分享一下.只所以诡异估计是自己知识面不够吧.线上的MHA一直没有开启自动切换,都是手动切换的,最近开启了自动切换以后,退出securecrt窗口以后发现监控进程 ...

随机推荐

  1. [原创]cocos2d-x研习录-第二阶 基本概念

    在Cocos2D-x引擎中,有几个非常重要的概念:导演(CCDirector).摄像机(CCCamera).场景(CCSecen).布景(CCLayer).精灵(CCSPrite)和动作(CCActi ...

  2. java 泛型接口示例

    /* * 泛型接口 */ interface Tool<t> { public void show(T t); //泛型方法 public <e> void print(E e ...

  3. C#操作Word的辅助类(word2003) 修改完善版

    转自:http://blog.csdn.net/jiutao_tang/article/details/6567608 该类在他人编写的几个类基础上扩展完善而来,主要功能有: (1)插入文本 (2)插 ...

  4. 【python】类的访问限制

    在Class内部,可以有属性和方法,而外部代码可以通过直接调用实例变量的方法来操作数据,这样,就隐藏了内部的复杂逻辑. 但是,从前面Student类的定义来看,外部代码还是可以自由地修改一个实例的na ...

  5. 服务发现之 Etcd VS Consul

    抄自这里 *********************************************************************************************** ...

  6. C++中没有finally,那么应该在如何关闭资源

    这是一篇有趣的帖子 原文链接: http://bbs.csdn.net/topics/90070457 楼主: C++中没有finally,那么应该在哪里关闭资源? C++的try{}catch(){ ...

  7. Hbase集群搭建及所有配置调优参数整理及API代码运行

    最近为了方便开发,在自己的虚拟机上搭建了三节点的Hadoop集群与Hbase集群,hadoop集群的搭建与zookeeper集群这里就不再详细说明,原来的笔记中记录过.这里将hbase配置参数进行相应 ...

  8. Linux Install VirtualBox

    添加源: cd /etc/yum.repos.dwget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo 下面3个 ...

  9. LeetCode 342. Power of Four

    Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...

  10. 创建线程方式-NSOperation

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...