Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting results of ps by start time

Tags:

unix

sorting

ps

I'm displaying information about the current processes using this variety of the ps command:

ps -eo pid,start,stime,command

How can I sort these results by start?

I've read man ps and tried -m, -r and -v sorting options. Unfortunately I haven't been able to use these options to sort by start.

like image 714
SundayMonday Avatar asked Dec 01 '11 00:12

SundayMonday


1 Answers

You use etime. That's elapsed time, in days, hours, etc. which is suitable for sorting numerically. If it's the first column, I think ps will sort by it automatically.

Otherwise, you can override sort order by using --sort, but make sure it is after the -o option, example:

ps -o pid,user:32,start,etime,state,time,vsz,args --sort=etime
like image 126
Bobby Jack Avatar answered Sep 27 '22 17:09

Bobby Jack