全球主机交流论坛

标题: 脚本大佬看过来,求个kill掉占用内存超过90%以上的程序脚本 [打印本页]

作者: 6156264    时间: 2021-1-16 10:33
标题: 脚本大佬看过来,求个kill掉占用内存超过90%以上的程序脚本
脚本大佬看过来,求个shell脚本,kill掉占用内存超过90%以上的程序,有些大佬会说去百度,但搜索到的结果都不理想(因为自己是小白)。
给大佬递烟上茶了
作者: wifitry    时间: 2021-1-16 10:34
楼下大佬来
作者: 6156264    时间: 2021-1-16 10:36
wifitry 发表于 2021-1-16 10:34
楼下大佬来

大佬,都快神仙了还这么水
作者: zxxx    时间: 2021-1-16 10:43
http://manpages.ubuntu.com/manpages/xenial/man1/cpulimit.1.html
作者: 6156264    时间: 2021-1-16 10:47
zxxx 发表于 2021-1-16 10:43
http://manpages.ubuntu.com/manpages/xenial/man1/cpulimit.1.html

大佬,没太看懂,这不是CPU的吗?能否给个具体的示例呢
作者: ken3    时间: 2021-1-16 10:55
ps -aux | awk '{print$2,$4}'|awk '{if($2>=90)print}' |awk '{print$1}' | xargs kill -9
作者: 6156264    时间: 2021-1-16 11:34
ken3 发表于 2021-1-16 10:55
ps -aux | awk '{print$2,$4}'|awk '{if($2>=90)print}' |awk '{print$1}' | xargs kill -9

ps -aux | awk '{print$2,$4}'|awk '{if($2>=90)print}' |awk '{print$1}' | xargs kill -9

Usage:
kill [options] <pid|name> [...]

Options:
-a, --all              do not restrict the name-to-pid conversion to processes
                        with the same uid as the present process
-s, --signal <sig>     send specified signal
-q, --queue <sig>      use sigqueue(2) rather than kill(2)
-p, --pid              print pids without signaling them
-l, --list [=<signal>] list signal names, or convert one to a name
-L, --table            list signal names and numbers

-h, --help     display this help and exit
-V, --version  output version information and exit

For more details see kill(1).



大佬,这样?
作者: ken3    时间: 2021-1-16 11:35
6156264 发表于 2021-1-16 11:34
ps -aux | awk '{print$2,$4}'|awk '{if($2>=90)print}' |awk '{print$1}' | xargs kill -9

Usage:

前面删选进程号 没大于90%得呀  kill  命令收到了空参 ,等于没执行
作者: ken3    时间: 2021-1-16 11:36
6156264 发表于 2021-1-16 11:34
ps -aux | awk '{print$2,$4}'|awk '{if($2>=90)print}' |awk '{print$1}' | xargs kill -9

Usage:

写个计划任务 每五分钟跑一次就好了
作者: 3333    时间: 2021-1-16 12:13
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 全球主机交流论坛 (https://443502.xyz/) Powered by Discuz! X3.4