Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way for me to review cpu or memory usage on my ubuntu linux server? I've noticed my server (lamp set up) being slow at times, but by the time I log in as root and run a PS command, everything may have returned to normal.

It would be great to review a log of what resources different parts of the server consumed.

share|improve this question
up vote 7 down vote accepted

The sysstat collection of tools contains sar which is able to save system activity information:

share|improve this answer

Use dstat -ta --top-cpu


If you want to log to a file you can use:

dstat -ta --top-cpu --noheader --output systemstats.csv

share|improve this answer
as of v 0.7 it's top-cpu not topcpu. Don't know what it was before that. – cori Jan 19 '11 at 16:19

You could run MRTG to graph various aspects of the server, such as CPU usage, RAM usage, number of processes. It is very useful for servers without a GUI as it creates images for displaying on web pages.

If you have GNOME installed you can monitor system resources using the System Monitor application.

Alternatively you could run something like this every minute from cron:

top -n 1 -b | head >> logfile

which will log uptime, users, load averages, number of processes, CPU usage, memory/swap usage and the top three resource hungry processes into a file for viewing later. -n 1 runs top once

As you specifically mention you run Ubuntu I believe you can get this monitored by Canonical using Landscape.

share|improve this answer
+1 Your alternative answer (using top with cron) is helpful for use on a tiny server where I do not want to keep installing more 'stuff'. – whitebeard Oct 29 '15 at 23:52
dead link to "landscape" – Nicholas DiPiazza Jun 27 at 17:44

Run sar in daemon mode. You can review a variety of information in detail after the fact. Try running sar in the foreground with something like 10 iterations over 10 seconds to get an idea what information is available.

share|improve this answer

vmstat and iostat , mytop and apache top may also be help you pin point the bottleneck.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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