Often times it may be necessary to save information regarding your linux memory hogs. You can do so with a very straight forward and simple command. The TOP command displays process information. By adding some parameters and file destination to it we can get the top processes piped out to file we can use for analysis.
top -b -i -n 20 >> /tmp/top_procs
Here is what this command is actually doing:
top: invokes the TOP command which queries for the running processes.
-b: starts TOP up in batch mode which basically means that it runs until it is killed or until the “-n” parameter is sent to it.
-i: this is toggle to show or hide idle processes from the query
-n: as referenced above this stops the collection of data
>> /tmp/top_procs: This outputs the result to a file that we can use to store the data.