Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I checked few programs such as htop or top command but couldn't find any features for logging per minute.

Is there a way to do that for tracking memory issues ?

edit: I was using linode and decided to use Longview.

share|improve this question

Install and configure the sysstat package, which does just what you're asking for.

sudo apt-get install sysstat
share|improve this answer

If I were doing this I'd probably script something up with RRDtool.

RRDtool is something that is built for interval-based data-collection and then building graphs off the back of the data. If you've ever seen a netgraph on an ISPs control panel, it was probably done with RRDtool.

How you implement it is up to you. There are "pure" bash solutions with cron but there are also nice Python and Perl options floating around out there too:

If you want a lot more than this, check out Munin. This uses RRDtool prolifically to log a whole load of system data and generates static HTML pages at a set interval.

share|improve this answer

vmstat -S M 60 would do (in megabytes).

You only have to remember that actually free RAM is "free + cache + buf".

For logging purpose it might have sense to print it out time stamped which can be accomplished in various ways, for e. g.:

vmstat -nS M 60 | while read _vmstat; do echo $(date --rfc-3339=seconds) $_vmstat; done

share|improve this answer

There is one more way to do this. By using cron jobs we can get this.

* * * * * username /path/to/./

the script is simply

echo "$(date +%Y%m%d-%H%M%S) $(free -mt | awk 'END{print $4}')" >> ~/memlog.txt

before placing the script do

chmod +x

so create above script and do it as I said then place the script at /usr/bin location . then open your /etc/crontab with

sudo nano /etc/crontab

and place the first line there . That script executes for every minute and gives memory details for every minute .

So finally that log.txt file will hold the Memory log details for every minute.

and I have got one more useful information for you that

watch cat log.txt will show the log.txt file in terminal and it will update the content in the current terminal it self with one time typing you can have live watch of the log.txt file.

share|improve this answer
Writing the date/time on the same might be a good idea so there's a reference point. Something like this: echo "$(date +%Y%m%d-%H%M%S) $(free -mt | awk 'END{print $4}')" >> ~/memlog.txt – Oli Mar 14 '13 at 14:25
I made the edit @Oli . Thank you very much for the suggestion. – Raja Mar 14 '13 at 14:30

Here my trick. With this command I append reports of free, vmstat and top into txt files every 5s.

 watch -n 5 'free -mt  >> free-report.txt && vmstat -S M >> vm-report.txt && top -b -n1 >> top-report.txt'
share|improve this answer
None of these commands need sudo. – muru Feb 6 '15 at 9:41

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.