4

On Ubuntu 20.04.3, calling ps -e -o args,pid,etime,%cpu,%mem --forest | egrep "firefox|PID" | grep -v grep gives me the following result:

COMMAND                         PID     ELAPSED %CPU %MEM
 \_ /usr/lib/firefox/firefo    5730    01:58:40 20.8  4.9
 |   \_ /usr/lib/firefox/fi    5811    01:58:39  0.0  0.2
 |   \_ /usr/lib/firefox/fi    5841    01:58:39  0.1  0.7
 |   \_ /usr/lib/firefox/fi    5895    01:58:39  0.0  0.9
 |   \_ /usr/lib/firefox/fi    5926    01:58:39  4.3  2.0
 |   \_ /usr/lib/firefox/fi    6000    01:58:38 21.7  2.0
 |   \_ /usr/lib/firefox/fi    6094    01:58:32  4.2  0.3
 |   \_ /usr/lib/firefox/fi    7004    01:54:00  1.4  2.0
 |   \_ /usr/lib/firefox/fi    7648    01:37:06  0.8  1.9
 |   \_ /usr/lib/firefox/fi    8351    01:31:35  1.0  1.0
 |   \_ /usr/lib/firefox/fi   12159       45:04  3.5  2.3
 |   \_ /usr/lib/firefox/fi   15712       03:56  2.0  0.9
 |   \_ /usr/lib/firefox/fi   15833       03:25  1.4  0.9
 |   \_ /usr/lib/firefox/fi   16878       02:39  0.0  0.4
 |   \_ /usr/lib/firefox/fi   16924       02:30  0.0  0.4
 |   \_ /usr/lib/firefox/fi   16962       02:24  0.0  0.4

which is what I want except for the shortened command line. Adding ww to ps (ps -eww) does not change the output. ps auxww --forest | egrep "firefox|PID" | grep -v grep works, but in BSD style and not with the columns I want.

1 Answer 1

7

To output the full command line, regardless of length, args needs to come last:

ps -e -o pid,etime,%cpu,%mem,args --forest

If you want to keep args first, you can specify an alternative header name with the width you want — but that will still truncate command lines which are longer than the header name:

ps -e -o args=args-----------------------------------------------------,pid,etime,%cpu,%mem --forest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.