Ubuntu: How to record memory usage?



Question:

I need a program or tool to record the memory usage ( RAM ) and save it to a file so i can take the file and open it. so i can see the result and make the comparison with other by myself.


Solution:1

You can use the following command in bash like so:

for i in `seq 0 60`; do    echo `cat /proc/meminfo | grep Active: | sed 's/Active: //g'` >> usage.txt    sleep 1m  done  

This command will record the current memory use to a file named 'usage.txt' every minute for the duration of 1 hour.

If you wish, you can change the usage.txt part of the command to save under a different name. You can also change the sleep 1m command to alter the time between each entry and the '60' in the seq section at the top to change the number of entries to be recorded.

When you have finished making your entries, you will have a text file of entries that can be imported into a spreadsheet for easy comparison.

EDIT: If you wish to also record the total memory with each entry, you can use the following commands:

for i in `seq 0 60`; do    echo `cat /proc/meminfo | grep Active: | sed 's/Active: //g'`/`cat /proc/meminfo | grep MemTotal: | sed 's/MemTotal: //g'` >> usage.txt    sleep 1m  done  

These commands will instead record entries in the form of <active>/<total>


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »