How To Use watch Command with Quicker Intervals
watch ifconfig command with 0.2s interval
Sometimes you need to monitor a progress of something in your Linux system - how a file size changes or network traffic gets tracked for a particular interface. There are many scenarios where watch command is handy.
Basic watch command usage
Come up with a command that generates the output you want monitored, and pass this command to watch command as parameters.
For instance, if I run ifconfig wlp2s0, it will give me the current state of the WiFi interface on my XPS laptop:
As you can see, some parameters are counters - RX packets and bytes, TX packets and bytes. So if you want to watch how they’re updated in nearly real time, you can use watch command:
By default watch command uses interval of 2sec - meaning it will refresh output every 2 seconds by re-running the same command you specified.
It will look like this:
Quicker Intervals for watch command
A friend reminded me the other day, that in Linux it’s actually possible to make watch command wait a lot less between re-runs of the commands you pass to it. You can go as far as making watch re-run every 0.1s, but even 0.2s is going to be 10x better than default - so the counters in my example will now be updating almost instantly.
Just use the -n parameter to specify new time interval:
Notice how it says Every 0.2s now at the top left corner:
See Also
watch ifconfig command with 0.2s interval
Sometimes you need to monitor a progress of something in your Linux system - how a file size changes or network traffic gets tracked for a particular interface. There are many scenarios where watch command is handy.
Basic watch command usage
Come up with a command that generates the output you want monitored, and pass this command to watch command as parameters.
For instance, if I run ifconfig wlp2s0, it will give me the current state of the WiFi interface on my XPS laptop:
As you can see, some parameters are counters - RX packets and bytes, TX packets and bytes. So if you want to watch how they’re updated in nearly real time, you can use watch command:
By default watch command uses interval of 2sec - meaning it will refresh output every 2 seconds by re-running the same command you specified.
It will look like this:
Quicker Intervals for watch command
A friend reminded me the other day, that in Linux it’s actually possible to make watch command wait a lot less between re-runs of the commands you pass to it. You can go as far as making watch re-run every 0.1s, but even 0.2s is going to be 10x better than default - so the counters in my example will now be updating almost instantly.
Just use the -n parameter to specify new time interval:
Notice how it says Every 0.2s now at the top left corner: