0

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?

5
  • cognitivedissonance.ca/cogware/plog <- Tracks per process and not the system as a whole.
    – goldilocks
    Commented Jan 25, 2017 at 15:30
  • I am looking for overall cpu load not per process
    – ThN
    Commented Jan 25, 2017 at 16:04
  • @goldilocks: with a theme like that, the software must be trustworthy :P
    – Jacobm001
    Commented Jan 25, 2017 at 16:24
  • @goldilocks I have tried the answer. Apparently, syrupy is not part of the repository and my Pi already has top but that doesn't log.
    – ThN
    Commented Jan 25, 2017 at 17:07
  • I'll reopen this since it is a bit more focussed than the duplicate; if all you want is CPU time there are various ways to do this. See here for some ideas (I'll recommend just skipping to the second half of my answer there about parsing /proc/stat).
    – goldilocks
    Commented Jan 25, 2017 at 17:13

1 Answer 1

1

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

3
  • I suppose you run this on the terminal. I did that and got bash syntax error it is complaining about the semicolon.
    – ThN
    Commented 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)
    – mperlet
    Commented Jan 31, 2017 at 9:18
  • mine is 4.3.30(1)-release
    – ThN
    Commented Jan 31, 2017 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.