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. linux C之access函数(转-追梦的小鸟)

    access():判断是否具有存取文件的权限 相关函数    stat,open,chmod,chown,setuid,setgid表头文件    #include<unistd.h>定义 ...

  2. NOIP2015 跳石头

    一年一度的“跳石头”比赛又要开始了! 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 N块岩石(不含起点和终点的岩石). ...

  3. JavaSE坦克网络版

    02.1.建立Server(保持这个TankServer一直运行) package server; public class TankServer { public static void main( ...

  4. LeetCode【169. Majority Element】

    Given an array of size n, find the majority element. The majority element is the element that appear ...

  5. MFC 中编辑框数字限制范围

    http://www.cnblogs.com/ziwuge/archive/2011/11/15/2249541.html void CSAAlt::OnEnChangeSlocp()//样本盘号输入 ...

  6. spring boot Swagger 集成

    1. pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://ww ...

  7. MVC 记录操作日志与过滤特殊字符

    最近进行的MVC系统需要用到记录操作日志和过滤特殊字符的功能,如果每个action中都调用记录日志的方法就太麻烦了,所以根据需要结合mvc的过滤机制 写了个特殊字符验证与记录操作日志的公用类: pub ...

  8. SQL 查询某个表被哪些存储过程使用到

    --1.查询某个表被哪些存储过程使用到 : select distinct object_name(id) from syscomments where id in (select object_id ...

  9. 关于动态生成data组件

    /*! * WeX5 v3 (http://www.justep.com) * Copyright 2015 Justep, Inc. * Licensed under Apache License, ...

  10. 创建MySQL 用户

    create user 'lixianming'@'localhost' identified by 'lxm123456'; grant all on art.* to 'lixianming'@' ...