大网数据广告活动
服务器运维问答

How to find what processes were running at a time in the past?

· 52CE 我爱测

I am asked to investigate a high CPU usage alert which occurred this morning. I used sar -p and saw the high CPU usage showing up at that time Next I used ps -eo pcpu,pid,user,args | sort -r -k1 | less to list the top 10 memory h…

问题原文

原帖链接 · juniorbansal · CC BY-SA 3.0

I am asked to investigate a high CPU usage alert which occurred this morning. I used sar -p and saw the high CPU usage showing up at that time

Next I used ps -eo pcpu,pid,user,args | sort -r -k1 | less to list the top 10 memory hogs at this hour

Now how do I find out what processes caused the bottleneck at that specific time in the morning. I am a java developer and not a Linux expert.

Is it even possible?

已采纳解答

原帖链接 · Thomas · CC BY-SA 3.0

There are several options:

  1. use a script which writes needed data on a regular basis to a logfile. You could use cron to write the output of ps (and other commands) every x minutes into a logfile.
  2. Better it would be to use a specialized program, which does this for you. atop is very good at this, at it takes care of logfile retention.

atop is available via the EPEL repo for CentOS/RHEL/Fedora and via the default repos of Debian/Ubuntu.

You can use atop like a normal real-time top utility, with slightly different behaviour (check out the manpage for keystrokes).

The more interesting part is: Once installed a daemon starts logging data into /var/log/atop and you can read these files with atop again:

atop -r /var/log/atop/atop_20160128

You have then access to all 'top' like functions (sorting/looking at memory/CPU/IO usage, etc.) and you can jump 10 minutes forward in time via 't' and 10 minutes back with 'T' or jump at a specific time via 'b'.

Check out the atop manpage and google has lots of howtos about it.

There might be other solutions, but atop is easy to understand and use and a good start before doing some more bespoke setups.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。