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.
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'Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
