Linux Watch Command Tutorial With Examples

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Some time generally long running operations like copying disk needs to track the change like disk usage or change of size of file. We generally run same command again and again but this is very cumbersome way yo see progress. Linux users created a “watch” application to make things better. When we use “watch” we can get change with specified interval times.

Syntax

We will use options with to change behavior of the watch command. COMMAND is the command we want to run with given intervals.

Help

We can print help information about the watch command with the -h option.

Help

Help

Just Watch

We will use watch command without providing any options. We will provide ls -lh command and run this command at 2 seconds interval. The default interval is 2 seconds.

Just Watch

Just Watch

As we can see from screenshot all files and folders are listed and will be refreshed in 2 seconds interval.

Exit or Quit

While running watch it will not end automatically. We must kill the watch process if we want to end. The simple way to end watch is using following shortcut.

Set Interval

Default interval value for watch is 2 seconds. In each interval provided command runs and the output is refreshed. We may need to change 2 seconds interval more suitable for our situation. -n option can be used to change default interval. We change ls -lh command interval to 5 seconds in the following example.

LEARN MORE  Linux Uptime Command Tutorial With Examples To Display Uptime

Set Interval

Set Interval

Remove Header

We can remote the watch title so we just get command output if we want to use the output from different applications.

Remove Header

Remove Header

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)