你如何杀死所有超过特定年龄的 Linux 进程? [英] How do you kill all Linux processes that are older than a certain age?
本文介绍了你如何杀死所有超过特定年龄的 Linux 进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在某个服务器上遇到了一些类似僵尸的进程的问题,这些进程需要时不时地被杀死.我如何才能最好地识别运行时间超过一个小时左右的那些?
I have a problem with some zombie-like processes on a certain server that need to be killed every now and then. How can I best identify the ones that have run for longer than an hour or so?
推荐答案
如果他们只是需要被杀死:
If they just need to be killed:
if [[ "$(uname)" = "Linux" ]];then killall --older-than 1h someprocessname;fi
如果你想看看它匹配的是什么
If you want to see what it's matching
if [[ "$(uname)" = "Linux" ]];then killall -i --older-than 1h someprocessname;fi
-i
标志将为每个进程匹配提示您是/否.
The -i
flag will prompt you with yes/no for each process match.
这篇关于你如何杀死所有超过特定年龄的 Linux 进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文