I have used top
to see the memory usage at the moment. But I would like to monitor the memory usage over a period of time. E.g start monitoring and then execute a few commands, and final stop the monitoring and see how much memory that have been used during the period.
How can I do this on Ubuntu Server?
I guess I could start a cronjob every 5th second or so, and invoke a command that log the current memory usage in a textfile. But what command should I use to get the current memory usage in a format that is easy to log to a text file?
Best Answer
I recommend combining the previous answers
Note that Linux likes to use any extra memory to cache hard drive blocks. So you don't want to look at just the free
Mem
. You want to look at thefree
column of the-/+ buffers/cache:
row. This shows how much memory is available to applications. So I just ranfree -m
and got this:I know that I'm using 1528 MB and have 2170 MB free.
Note: To stop this
watch
cycle you can just press Ctrl+C.