--- layout: page category-page: intermediate category-title: Intermediate commands tags: watch repeat track analyse seconds author: Claudio Maggioni title: watch ---
The watch
command is a system utility able to execute a command
every n seconds by clearing the screen and displaying the
output of the command each time the interval is over. This command is very
simple to use and very effective: it can be used to check the size in bytes
of a file while downloading it, or it can be used on Linux to jiggle
around the mouse every ~5 minutes with the command xdotool
in
order to keep the computer awake.
watch
has a very simple syntax: the amount in seconds to wait
between executions is specified in seconds using the -n
flag
and the default value is 2. Also, differences between older and
newer outputs are highlighted if the -d
flag is used.
watch -n 5 du -h ubuntu.iso
watch -d cat site.html