How to monitor and record CPU & Memory usage in linux
If you are looking to monitor and record CPU & Memory usage in linux then this is one of many ways to do so. This is the method I used which worked nicely. The output can then be imported to a spreadsheet and displayed nicely using charts.
Example:
# top -b -i >output.file
The following are a few of the available options and was taken from man top,
-b : Batch mode operation
Starts top in ‘Batch mode’, which could be useful for sending out-
put from top to other programs or to a file. In this mode, top
will not accept input and runs until the iterations limit you’ve
set with the ‘-n’ command-line option or until killed.
-i : Idle Processes toggle
Starts top with the last remembered ‘i’ state reversed. When this
toggle is Off, tasks that are idled or zombied will not be dis-
played.
-p : Monitor PIDs as: -pN1 -pN2 … or -pN1, N2 [,...]
Monitor only processes with specified process IDs. This option
can be given up to 20 times, or you can provide a comma delimited
list with up to 20 pids. Co-mingling both approaches is permitted.
I hope this helps
Did you find this post usefull? Why not leave a comment below and let us know. Or, if you still need help, post it in our Forums.

Thanks .. this is exactly what I needed.