# How to use watch command on Linux

**URL:** https://www.compsmag.com/blogs/how-to-use-watch-command-on-linux/
**Author:** Ayushi Chauhan
**Published:** 2022-09-06
**Updated:** 2022-09-06
**Categories:** Blogs
**Tags:** Blogs Daily, Computer Guides, guiderobert, Guides and Tutorials, guiding12, How To Guide, How To Guides, Linux Guides, Originals How to, Tips, Tricks
**Reading Time:** 4 min

---

Today, in this article, we wear you how to **use watch command in linux**.  Occasionally, we can track changes in the output using the Linux clock.  It is advantageous to reflect the current state of events in an operating system in real time.  By default it runs the program every two seconds, but using the -n or -interval arguments a different frame can be specified.

When combined with different pipeline instructions, Watch also allows users to maintain control over adding and deleting files.  When you press CTRL+C, Watch will pause the terminal while running simultaneously.  Linux observation can also be useful when you need to continually monitor script output or troubleshoot a problem.  All Linux distributions provide the watch command by default, along with a number of features.  We have mentioned below the steps to use watch command in Linux.

## Steps to use watch command on Linux

### Run command every 2 seconds

**Step 1:** By default, **the watch command is executed** after every 2 seconds and shows the output on the terminal.  It continues to work until stopped by the user.  The watch command uses the following syntax:

> watch

**Step 2:**Where**option**> are the parameters that we will discuss later in this article and**command**> is another command you want to run by the watch utility.

> watch date

### Execute command every N seconds

**Step 1:**The Watch command update interval can be overridden.  means you can **change refresh interval** of 2 seconds to the desired interval as well.  Syntax:

> watch -n

**Step 2:**Where**interval in seconds**> is the update interval in seconds and**command**> is another command you want to run by the watch utility.

> watch -n 5 date

### Highlighting the differences between updates

**Step 1:**You can also highlight the differences between the previous output and the current output.  So instead of**reading all output**, you can keep an eye on the changes.  Syntax:

> watch -d

**Step 2:**However, if the interval between updates is too short, it will be a challenge to review the differences, so you should **set a reasonable refresh interval**.

> watch -n 5 -d date

### Hide header in output

**Step 1:**The output of the Watch command shows a **header containing time range**, **command**, **system name**and **system date**.  However, if you don't want to see that part, you can also hide it.  Syntax:

> watch -t watch -t date

### Error beep

**Step 1:**The watch command can also beep if an update fails.  For this to happen, it may first be necessary to verify that the beeper packet is **installed** or not.  If not installed, you can **install it using the following command**:

> sudo apt install beep

**Step 2: Syntax**:

> watch -b date

### exit in change

**Step 1:**By default, the watch command continues to run until manually stopped by the user.  However, you can do it **exit** identify a **change in output** also.  Syntax:

> watch -g watch -n 10 -g data

**Step 2:**This **returns a certain status** which can be obtained using the command below:

> echo $?

### Using big commands

**Step 1:**You can use other commands with the watch command more cleanly.  There are several ways to do this.  You may **use  sign** after the watch command and its options.

> watch -n 10 -d

**Step 2:**You can also write you complete**custom command** also enclosed in single quotes.

> watch ''

## Final Words

We hope you like our article about how to use watch command on Linux.  One of the most popular Linux commands among power users is watch, which allows them to run a specific command regularly and show the output in a console or terminal window.  With the watch command, you can run commands repeatedly until you stop them or until you encounter a circumstance that automatically ends the loop.  When you need to wait for something to change before moving on to the next job, this can be very helpful.

---

*End of Article*