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

最新文章

  1. 用Go语言做产品半年的一些感觉
  2. iOS开发--应用崩溃日志揭秘(二)
  3. 一些asp.net使用
  4. 103. Binary Tree Zigzag Level Order Traversal
  5. IE10 下兼容性问题
  6. clrscr( )用法
  7. ASP.NET MVC基于标注特性的Model验证:一个Model,多种验证规则
  8. UILabel图文混排显示图片和文字
  9. jquert 判断checkbox 是否选中
  10. ELF 动态链接 so的动态符号表(.dynsym)
  11. Prism框架研究(二)
  12. python扩展包的升级
  13. 多用户角色权限访问模块问题”的解决思路( 位运算 + ActionFilterAttribute )
  14. 【MATLAB】读取和写入文本文件
  15. [转]glyphicons-halflings-regular字体 图标
  16. 记录 iOS 各种跳转到系统应用
  17. win7环境中使用notepad++配置python IDE
  18. PAT 1119 Pre- and Post-order Traversals [二叉树遍历][难]
  19. mysql 命令连接
  20. R语言笔记001——读取csv格式数据

热门文章

  1. UIApplication的使用
  2. 2016HUAS_ACM暑假集训2E - I Hate It
  3. 简单的鼠标可拖动div 兼容IE/FF
  4. Android多媒体分析-通过MediaStore获取Audio信息
  5. UIView的使用
  6. Linxu IO测试软件
  7. 【uTenux实验】内存池管理(固定内存池和可变内存池)
  8. 关于华为x2中的外置SDCard的使用
  9. CPS冥想 - 2 手撸控制流
  10. java Util