无法过滤Etime,请帮助我找出运行超过24小时的进程/命令。
-1
A
回答
0
ps -ef
的ps -ef
等效为ps -eo uid,pid,ppid,c,stime,tty,time,cmd
etime ELAPSED elapsed time since the process was started, in the
form [[DD-]hh:]mm:ss.
start STARTED time the command started. If the process was started
less than 24 hours ago, the output format is
"HH:MM:SS", else it is " <mm dd" (where Mmm is a
three-letter month name). See also lstart, bsdstart,
start_time, and stime.
0
你可以尝试这样就知道多久进程已运行。
ps -o etime= -p "your_pid"
有关国旗-o etime
的信息它提供了经过的时间。
这会返回经过时间
或另一种方式是
ps -eo pid,comm,cmd,start,etime | grep -iv <your_pid>
+1
我还没有更新我的工作代码,请在下面找到: - ps -eo pid,etime,cmd | grep python | awk'substr($ 0,9,1)==“ - ”'| awk {'print $ 1'} – Challa
0
试用一下这个:
ps -eo etimes,cmd | awk '{if ($1 >= 86400) print $2}'
etimes
将返回在几秒钟的时间,因此, ,你可以使用>=
所需的时间
您可以扩展此搜索和例如只杀所需的过程:
kill $(ps -eo etimes,pid,cmd | awk '{if ($3 == "sleep" && $1 >= 30) print $2}')
在这种情况下,它会搜索cmd
睡眠,只会杀死它,如果已经运行了多个过程运行时间超过30秒。
要检查cmd
开始用绳子,你可以使用:
ps -eo etimes,pid,cmd | awk '{if ($3~/^sle/ && $1 >= 30) print $2}
的$3~/^sle/
将检查命令启动sle
。
希望这可以帮助你或给你一些想法。
0
使用命令
alp ❱ ps -e -o etime,pid
ELAPSED PID
03:10:06 1
03:10:06 2
03:10:06 3
03:10:06 5
03:10:06 7
03:10:06 8
03:10:06 9
03:10:06 10
03:10:06 11
etime
的ps
在此格式,因为你需要24
很长一段时间,我们可以试试(我用03
,因为我没有一个24
长的时间过程):
alp ❱ ps -e -o etime,pid | grep -P '^ +03:..:..'
03:14:16 1
03:14:16 2
03:14:16 3
03:14:16 5
03:14:16 7
03:14:16 8
03:14:16 9
03:14:16 10
03:14:16 11
现在我们可以消除(=摆脱)那些时间:
alp ❱ ps -e -o etime,pid | grep -Po '^ +03:..:..\K +\d+'
1
2
3
5
7
8
9
10
11
,最终这个输出传递给xargs
alp ❱ ps -e -o etime,pid | grep -Po '^ +03:..:..\K +\d+' | xargs -I xxx echo xxx
1
2
3
5
7
8
9
10
11
因此,你应该在的地方使用正则表达式部分24:..:..
和kill
或echo
相关问题
- 1. 杀死长时间运行Fastcgi进程
- 2. 运行bash命令并在超过特定时间时将它杀死
- 3. 通过PID在Erlang中杀死进程
- 4. 在超过指定时间的bash中杀死进程?
- 5. 比较超过24小时的时间
- 6. 如何从pid文件中查杀时杀死子进程
- 7. 线程杀死超时
- 8. 查询运行时间超过命令超时SSIS
- 9. 杀死运行超过两分钟的winword进程
- 10. 阿帕奇杀死很长时间的运行过程
- 11. 如何通过Runtime.exec()命令在java中杀死进程时获得异常?
- 12. 如果运行时间过长,间歇性无法杀死进程
- 13. 杀死进程杀死其他进程
- 14. Perl IPC ::在父母死亡时运行,杀死进程
- 15. 如何增加使用'超时'命令运行的进程的超时限制
- 16. 使用php命令杀死进程
- 17. 杀死进程和PID回收
- 18. Linux杀死进程kill -9 PID
- 19. Datediff超过24小时
- 20. 运行命令,然后而不杀死命令
- 21. 杀死进程
- 22. 杀死/卸载后进程运行
- 23. 杀死长时间运行失控程序的程序
- 24. UNIX中的杀死命令
- 25. 杀死ssh会话杀死正在运行的进程
- 26. 超时并杀死并行matlab执行
- 27. 如何通过Pro * C杀死长时间运行的查询?
- 28. 如何杀死一个PID在PID文件中的进程?
- 29. 超时时杀死或终止子进程?
- 30. 在ruby中运行控制台命令,获取子进程的PID,并在几秒钟内杀死它
你能粘贴您的使用,以确定它运行多个进程的shell命令比24小时? – LethalProgrammer
https://serverfault.com/q/181477/94862 – nbari