I need to examine how my CPU is performing. I could simply open the task manager, but I will have to sit in front of the monitor long time. My problem is that CPU seems to be spiking or overloading and crashing all the programs that are running. So, I want to be able to log it somewhere say every second or so. Is there way to log CPU load?
1 Answer
You can run top
without reloading and write its output to a log to analyze it later.
while sleep 1; do top -n1 >> cpu.log; done
-
I suppose you run this on the terminal. I did that and got
bash syntax error
it is complaining about the semicolon.– ThNCommented Jan 27, 2017 at 13:57 -
whats your bash version? i tested it with
GNU bash, Version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
(fixed semicolon)– mperletCommented Jan 31, 2017 at 9:18 -
top
but that doesn't log./proc/stat
).