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