*********Introduction to Watch Command In Linux***********
Watch is Linux command that allows you to execute command or program periodically also shown your output on screen.This means that we shown your command output time to time. By default watch re-execute command or program every 2 seconds.The time can be easily change our requirement.
Watch is extremely easy to use in terminal of Linux. We have to just open a terminal and type below command
watch free -m
The above command will check your system free memory and update result of free commands for every two seconds.
How to change periodical time we have to just use -n option , that specifies the interval with which the command will be executed. This interval is specifies in seconds.
We have to run script.sh file in every 10 seconds, we have to specify following command.
watch -n 10 script.sh
Note that, we have to run this above command, we have to cd that directory and run that command or we have to specify absolute path.
Other useful option of watch command is,
-b : Create the beep sound if the exit of command is non-zero.
-c : Interpret the ANSI colour sequence.
-d : Highlight the changes in command output.
If we want to monitor logged-In user, server uptime and load average output in continuously phase every few seconds, then use the following commands as shown,
watch uptime

To exit this command we have to press Ctr + C
/////////////////////////////////////////////////////////////////////////////////////////////
Watch is Linux command that allows you to execute command or program periodically also shown your output on screen.This means that we shown your command output time to time. By default watch re-execute command or program every 2 seconds.The time can be easily change our requirement.
Watch is extremely easy to use in terminal of Linux. We have to just open a terminal and type below command
watch free -m
The above command will check your system free memory and update result of free commands for every two seconds.
How to change periodical time we have to just use -n option , that specifies the interval with which the command will be executed. This interval is specifies in seconds.
We have to run script.sh file in every 10 seconds, we have to specify following command.
watch -n 10 script.sh
Note that, we have to run this above command, we have to cd that directory and run that command or we have to specify absolute path.
Other useful option of watch command is,
-b : Create the beep sound if the exit of command is non-zero.
-c : Interpret the ANSI colour sequence.
-d : Highlight the changes in command output.
If we want to monitor logged-In user, server uptime and load average output in continuously phase every few seconds, then use the following commands as shown,
watch uptime

To exit this command we have to press Ctr + C
/////////////////////////////////////////////////////////////////////////////////////////////
No comments:
Post a Comment