When we run top command and If we type "T", it will sort based on the TIME+
I want to sort by "TIME+" in command line, using top -n 1
so that I can capture all the process in a file and analyse it one by one.
Note: It is CentOs
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
top -n 1 -b | tail -n +7 | sort -k 11Vb
top -n 1 -b: -b to avoid highlighting chars
tail -n +7: to skip the headers written by top
sort -k 11Vb: sort by the 11.th field, skipping white spaces, in a "version" sort mode
-k 11Vbr to have reverse order.
$ top -o TIME+ -n 1 >top.out
-o option is use to select which column to sort on,
-n 1 will make
top only update once before exiting.