I am on a Debian 8 System trying to determine the processes and their respective runtime of a certain user:
$ ps -u <user>
PID TTY TIME CMD
26038 ? 00:00:00 php5-fpm
26052 ? 00:00:00 php5-fpm
26950 ? 00:00:00 php5-fpm
27344 ? 00:00:00 php5-fpm
28292 ? 00:00:00 php5-fpm
28691 ? 01:54:21 python3 /usr/lo
$ which ps # ps is not aliased or so.
/bin/ps
Now I additionally want the elapsed time for the respective processes. So I tried:
$ ps -o cmd=,etime= -u <user>
php-fpm: pool <user> 00:36
php-fpm: pool <user> 00:36
php-fpm: pool <user> 00:24
php-fpm: pool <user> 00:18
php-fpm: pool <user> 00:04
python3 /usr/local/bin/fixw 17:39:44
However I want to have the short process names php-fpm
as in the first output, not the long names of the second one. I could not find any ways to so it, reading ps
's man page.
How do I get the CMD of output #1 with the elapsed time of output #2?
Solution @StephenKitt's answer was the missing hint. However, I needed to modify it slightly. Strange output:
$ ps -o comm=,etime= -u <user>
,etime=
php5-fpm
php5-fpm
php5-fpm
php5-fpm
php5-fpm
ps
python3 /usr/lo
Separated options work:
$ ps -o comm= -o etime= -u <user>
php5-fpm 00:55
php5-fpm 00:27
php5-fpm 00:24
php5-fpm 00:13
php5-fpm 00:08
python3 /usr/lo 17:49:38