Top First 4 Lines To A File
Thursday, July 30, 2009
If the first 4 lines details of top command needs to be logged to a output file with time interval use this shell command
top -b -d 2 | grep "top -" -A 4 > /tmp/output_file
Explanation :
top -b : send results to output with default time interval
top -d 2 : refresh top every 2 seconds
grep "top -" : grep the very first line of top output. ( It has the work "top -")
grep -A 4 : prints only 4 lines after first line