Operations 2 min read

Master Linux’s watch Command: Real‑Time Periodic Execution Made Easy

Learn how to use the Linux watch command to run any command at regular intervals, customize its behavior with options like -n, -d, and -t, and see practical examples such as monitoring memory usage and tracking file changes.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux’s watch Command: Real‑Time Periodic Execution Made Easy

watch: Periodic Command Execution

The watch command runs a given command repeatedly, displaying its output full-screen. It is included in virtually all Linux distributions and is handy for monitoring command results without manual re-execution.

Syntax

watch [options] [command]

Options

-n

: Set the interval in seconds (default is 2 s). -d: Highlight changed parts; -d=cumulative keeps all changed areas highlighted. -t: Turn off the header showing interval, command, and current time. -h: Show help information.

Arguments

command : The command to be executed periodically.

Examples

(1) Repeatedly run free -h

# watch free -h
# watch -n 5 free -h

(2) Monitor changes to data.txt in the current directory

# watch -d 'ls -l | grep data.txt'
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxBashsystem-monitoringwatchcommand-line
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.