Collect the current process and load state in top format.
Do not open an interactive display; take one update and exit with procps-ng top.
Which command is correct?
top -b uses batch mode and -n 1 limits the number of updates to one. This form is suitable for logs and pipelines.
Detailed explanation
top -d 1Incorrect. -d 1 sets a one-second delay but leaves top interactive and repeating.
Incorrect. -d 1 sets a one-second delay but leaves top interactive and repeating.
top -n 1Incorrect. Without -b, top remains an interactive display.
Incorrect. Without -b, top remains an interactive display.
top -b -n 1Correct. Batch mode plus one update prints one snapshot and exits.
Correct. Batch mode plus one update prints one snapshot and exits.
top -p 1Incorrect. -p selects a PID but does not make the display non-interactive or single-shot.
Incorrect. -p selects a PID but does not make the display non-interactive or single-shot.
Try it yourself
An example you can run in a temporary verification environment.
top -b -n 1 | head -n 1Expected result
top - で始まるシステム概要行(時刻と値は環境により変動)Key points
- -b is batch mode
- -n sets the update count
- -d sets the delay
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.