Inspect the one process identified by TASK_PID with ps.
Show PID, nice value, kernel priority, and command name in that order using procps-ng ps.
Which command is correct?
ps -o selects output columns. ni is the nice value, pri is the displayed scheduling priority, and comm is the short command name.
Detailed explanation
ps -p "$TASK_PID"Incorrect. It selects the PID but leaves the default columns and does not show the requested fields explicitly.
ps -o pid=,ni=,pri=,comm= -p "$TASK_PID"Correct. It selects PID, NI, PRI, and COMMAND for the requested process.
nice -n "$TASK_PID" psIncorrect. nice starts a command with an adjustment; it does not inspect an existing PID this way.
renice "$TASK_PID"Incorrect. renice changes or reports priority rather than formatting the requested ps columns.
Try it yourself
An example you can run in a temporary verification environment.
ps -o pid=,ni=,pri=,comm= -p "$$"Expected result
現在のBashのPID、NI、PRI、bashを含む1行(空白幅とPRIは環境依存)Key points
- ni is the nice column
- pri is the priority column
- -o selects the columns
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.