How to permanently set refresh interval for top command?

7,078

Solution 1

Personal configurations such as this may be saved to your ~/.toprc file by hitting SHIFT+W in the interactive top session.

From man top (or online):

 6b. PERSONAL Configuration File
   This  file is written as `$HOME/.your-name-4-top' + `rc'.  Use the
   `W' interactive command to create it or update it.

Solution 2

Why not just launch top with a preset interval like this top -d 5. Which will make top start preconfigured to update every 5 seconds.

Share:
7,078

Related videos on Youtube

Underoos
Author by

Underoos

Updated on September 18, 2022

Comments

  • Underoos
    Underoos almost 2 years

    I'm just looking at the tutorials for top command and came to know that the refresh interval can be overridden by hitting S on the keyboard while the top command is displaying information.

    The default value for refresh interval was 3 seconds. I was able to override the refresh interval to different value.

    However, when I quit and come back and try the top command again, it is refreshing the processes information again for every 3 seconds and not with the interval that I've set earlier.

    I was looking for a way to configure this interval permanently. I've looked at some articles where in they mentioned to use the toprc file in /etc directory for this configuration.

    But it doesn't seem like I have any such file in /etc or my home directory.

    How do I set the refresh interval for top command?

    I'm using Ubuntu 18.04.

  • Underoos
    Underoos over 4 years
    If I do that, I had to do top -d 5 everytime instead of top.
  • endrias
    endrias over 4 years
    Then save this as a one liner script named /bin/pot and you'll never have to save a personal config for each user, albeit at the modest price of having to type pot every time you want top
  • Déjà vu
    Déjà vu over 4 years
    What about an alias alias top="top -d 5"?
  • endrias
    endrias over 4 years
    alias top="top -d 5" works but only for the current shell, unless you make it permanent by sudo echo "alias top="top -d 5"" >> ~/.bashrc