I need to know the memory/CPU usage history from command line. My server is Debian (text mode only). Is it possible?

1 Answer 1


You can run the top command in batch mode by using the -b option, then dump that to a file.

On start up of your server, open a terminal, run the following commmand.

top -b > ~/cpu.txt

The sysstat collection of tools contains sar which is able to save system activity information: http://pagesperso-orange.fr/sebastien.godard/documentation.html

Regards, Paresh

  • Adding some sort by MEM options to top may help, like top -o %MEM -b, plus some head & tail snipping could show the top few "hogs"
    – Xen2050
    Mar 22, 2017 at 5:46
  • @Xen2050: Why ~/ ? What is ~/ ?
    – Ed S
    Mar 22, 2017 at 20:17
  • That's just a shortcut meaning your user's home directory. Read man bash for the "Tilde Expansion" section for more info
    – Xen2050
    Mar 22, 2017 at 20:37
  • @Xen2050, Is there a way to save in a file all information from "free" command ? I need it every 2 minutes: imgur.com/a/iOpIF
    – Ed S
    Mar 27, 2017 at 19:10
  • Or "vmstat" command
    – Ed S
    Mar 27, 2017 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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