8

I'm just looking at the tutorials for top command and came to know that the refresh interval can be overridden by hitting lower case 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.

0

2 Answers 2

11

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.
0
5

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.

4
  • If I do that, I had to do top -d 5 everytime instead of top.
    – Underoos
    Dec 15, 2019 at 18:06
  • 2
    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
    – endrias
    Dec 15, 2019 at 18:18
  • 5
    What about an alias alias top="top -d 5"?
    – Déjà vu
    Dec 16, 2019 at 12:35
  • 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
    – endrias
    Dec 16, 2019 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .