These are possible output formats for ps h -eo etime
ps h -eo etime
21-18:26:30 15:28:37 48:14 00:01
How to parse them into se
Works on AIX 7.1:
ps -eo etime,pid,comm | awk '{if (NR==1) {print "-1 ",$0} else {str=$1; sub(/-/, ":", str="0:0:"str); n=split(str,f,":"); print 86400*f[n-3]+3600*f[n-2]+60*f[n-1]+f[n]," ",$0}}' | sort -k1n