Target every process whose executable name is worker.
Send SIGTERM by name with killall instead of listing PIDs individually.
Which command is correct?
killall sends a signal to processes selected by name. Because it can affect several processes, confirm the name and scope before running it.
Detailed explanation
killall -TERM workerCorrect. killall -TERM worker sends TERM to matching worker processes.
Correct. killall -TERM worker sends TERM to matching worker processes.
kill -TERM workerIncorrect. kill expects numeric PIDs rather than a command name.
Incorrect. kill expects numeric PIDs rather than a command name.
pgrep workerIncorrect. pgrep lists matching PIDs but does not terminate them.
Incorrect. pgrep lists matching PIDs but does not terminate them.
killall -STOP workerIncorrect. STOP suspends processes rather than requesting termination.
Incorrect. STOP suspends processes rather than requesting termination.
Try it yourself
An example you can run in a temporary verification environment.
killall --version | head -n 1Expected result
killallのVersion情報(実装とVersionは環境により異なる)Key points
- killall targets by name
- -TERM requests termination
- Verify the target scope first
Notes
- Environment: psmisc 23.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.