About the watch command
watch
runs command repeatedly, displaying its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, command is run every 2 seconds and watch will run until interrupted.
For mor details about watch
command you can check the link.
Example of watch
Command
Example 1: Monitor temperature every 2 seconds on Pi4 device:
watch 'sensors | grep "temp1" | awk "{print \$2}"'
Example 2: Check the IP Address every 60 seconds:
watch -n 60 ip addr
-n 60
: Sets the interval to 60 seconds.ip addr
: The command to execute.
Example 2: Tracking Disk Usage with df
If you want to observe the disk usage of your system’s partitions at regular intervals, you can use:
watch -n 10 df -h
-n 10
: Runs thedf -h
command every 10 seconds.df -h
: Displays disk usage in a human-readable format.