3

Is there a way to run top with these filters by default:

filters: '%CPU>0.0' + '!COMMAND=top'

?

Can I pass that via command line options?

d0g
  • 143

2 Answers2

3

top -i

This option does exclude zombie and idle processes. And it sorts CPU usage greater than zero.

2

top:W to save current view configuration

Using W command through top interactive CLI. For more details see man top → Files.

An example, of the saved configuration:

more ~/.config/procps/toprc (Ubuntu 21.10)

top's Config File (Linux processes with windows)
Id:j, Mode_altscr=0, Mode_irixps=1, Delay_time=3.0, Curwin=0
Def fieldscur=���������&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
    winflags=2290996, sortindx=18, maxtasks=0, graph_cpus=0, graph_mems=0, double_up=0, combine_cpus=0
    summclr=1, msgsclr=1, headclr=3, taskclr=1
Job fieldscur=�����(���@<��)*+,-./012568>?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
    winflags=193844, sortindx=0, maxtasks=0, graph_cpus=0, graph_mems=0, double_up=0, combine_cpus=0
    summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=���<�����MBN�D34��&'()*+,-./0125689FGHIJKLOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
    winflags=193844, sortindx=21, maxtasks=0, graph_cpus=0, graph_mems=0, double_up=0, combine_cpus=0
    summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=�����������)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
    winflags=193844, sortindx=3, maxtasks=0, graph_cpus=0, graph_mems=0, double_up=0, combine_cpus=0
    summclr=3, msgsclr=3, headclr=2, taskclr=3
Fixed_widest=0, Summ_mscale=1, Task_mscale=0, Zero_suppress=0

begin: saved other filter data ------------------- window #0, osel_tot=2 type=111, filter=!COMMAND=top type=111, filter=%CPU>0.0 end : saved other filter data -------------------

~/.toprc (Ubuntu 18.04) top does not save or restore filters with W command. I don't know yet when it did change.

user.dz
  • 48,105
  • Hm, I tried that ... and it said Wrote to ... .toprc-- but then on next launch nothing was preserved. – d0g Jan 08 '22 at 22:52
  • @Dan which Ubuntu release do you have? Could you share the saved file though https://paste.ubuntu.com – user.dz Jan 08 '22 at 23:21