Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 393 Bytes

run-a-command-every-n-seconds.md

File metadata and controls

23 lines (15 loc) · 393 Bytes

Run A Command Every N Seconds

Category: Linux

Linux or macOS can run commands every n seconds using watch.

For example, to refresh the output of vmstat every 2 seconds:

watch -n2 vmstat

Highlight differences in output with the -d flag:

watch -d -n2 vmstat

Exit watching when the output changes with the -g flag:

watch -g -n2 vmstat