watch command in Linux allows you to execute the given command or script repeatedly. By default, it refreshes the command every 2 seconds.
Linux command watch | Execute command or script Repeatedly
![]() |
watch command in Linux |
Hello, guys welcome to the Linux command line tutorial.
Today, I'm going to show you how you can use "watch" command in Linux.
"watch" is an excellent command. Which can run scripts or command at a regular interval or repeatedly.
watch command
![]() |
watch command |
$watch yourCommand
![]() |
Output |
For example, I'm going to use "free" command with the "watch" command. So just say "watch free -h" and press ENTER
To Exit press ctrl+c
- If you use "watch" before any command. It executed repeatedly.
And you can see after Every 2 seconds this command is going to be executed.
By "default" the command will be executed at an interval of 2 seconds.
To change the frequency
If you want to increase the frequency to execute this command.
You can use the flag "-n" and then the "Number of seconds". Which you want to provide.
![]() |
watch command with -n flag |
$watch -n [numberofSeconds] [yourCommand]
For example, I want to use "1" second interval.
So I can just write "watch -n 1 free -h" and press ENTER
Now it's refreshing at a 1-second interval.
Conclusion
So this is how you can use "watch" command.
You can use this "watch" command with any command or even with the script.
I hope you've enjoyed this tutorial please rate comment and bye for now.
HAVE A NICE DAY💖