Is there a way to sort ps output by process start time, so newest are either at the top or bottom ?
On Linux ?
On SysV5 ?
On Mac ?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Along with the great answers above, sometimes I just want to see the top 20 offenders by process sorted descending by time, cpu% and memory usage.
For that I use:
ps auxww --sort=lstart | sort -r -k3,4 | head -20
This would be on a CentOS platform, though I've enjoyed the same results on Fedora as well.
Oh and for grins, I sometimes want to remove a set of processes, so I simply use a variant on the above that includes a bit of grep -v action, such as:
ps auxww --sort=lstart | sort -r -k3,4 | grep -v "sbin/httpd" | head -20
Try simple command:
ps | sort -k7 -n
-k7 for the time column and
-n for numeric.