These are possible output formats for ps h -eo etime
21-18:26:30
15:28:37
48:14
00:01
How to parse them into seconds?
- Please assume at least 3 digits for the days part as I don't know how long it can be.
- The output will be
egreped
to one only line so no need for a loop.
I just had to add my version, heavily based on the elegant perl one-liner by @andor (beautiful perl code!)
tail +2
doesn't work. On solaris,tail -n +2
doesn't work. So I try both to be sure.Here is how to compute the times and also sort your processes by their mean CPU usage over time
A version for Python: