
In UNIX & Linux, you can have a command to be repeatedly executing. The command will be keep refreshing on every x seconds/minutes. As an example, you want to execute command top and need the command to be repeatly execute on every 10 seconds.
# while true > do > top > sleep 10 > done Tasks: 102 total, 1 running, 101 sleeping, 0 stopped, 0 zombie Cpu(s): 2.0%us, 2.7%sy, 0.0%ni, 95.0%id, 0.3%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 507928k total, 498204k used, 9724k free, 18508k buffers Swap: 761852k total, 3020k used, 758832k free, 264308k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1779 root 20 0 120m 22m 15m S 3.0 4.6 0:01.38 konsole 868 root 20 0 80488 42m 4812 S 2.7 8.5 0:03.45 Xorg 1513 root 20 0 135m 31m 23m S 0.7 6.4 0:01.69 kwin 1688 root 9 -11 95276 5588 4028 S 0.7 1.1 0:07.17 pulseaudio 1 root 20 0 5180 2188 1824 S 0.0 0.4 0:00.55 systemd
• sleep 10 – time in seconds, so every 10 seconds, the command top will refresh.
Please be noted that the command will be terminated once you exit the terminal or press the CTRL+C.


