Repeatedly inspect the output of free -h in the terminal.
Refresh every five seconds until manually stopped.
Which command is appropriate?
watch repeatedly runs a command and refreshes the display. The -n option sets the interval in seconds.
Detailed explanation
watch -n 1 free -hIncorrect. It refreshes every one second, not every five seconds.
Incorrect. It refreshes every one second, not every five seconds.
watch -n 5 free -hCorrect. watch -n 5 reruns free -h every five seconds.
Correct. watch -n 5 reruns free -h every five seconds.
free -h 5Incorrect. free does not use a trailing number as a repeat interval.
Incorrect. free does not use a trailing number as a repeat interval.
sleep 5 free -hIncorrect. sleep delays once and does not repeat free -h.
Incorrect. sleep delays once and does not repeat free -h.
Try it yourself
An example you can run in a temporary verification environment.
watch --version | head -n 1Expected result
watch from procps-ngのVersion情報Key points
- watch repeats a command
- -n sets the interval
- Ctrl+C can stop it
Notes
- Environment: procps-ng 4.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.