When to use pkill
Use pkill only after reviewing the same selection with pgrep. It sends signals to every matching process, so narrow the account and use exact matching when that is the intended scope.
Syntax
pkill [OPTIONS] TEMPLATESquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Check for matches first
pgrep -a -u "$USER" -x sleepThe target process names and current-user restriction are checked without sending a signal.
Terminate only your own sleep test processes
pkill -TERM -u "$USER" -x sleepEvery exact-name sleep process owned by the current user receives a graceful termination signal.
Show help
pkill --helpUsage information is displayed for the installed implementation.
Notes and limitations
- pkill signals all matching processes. Inspect the same filter with pgrep before using it.
- A broad -f pattern can match unintended commands and shells.
Common questions and troubleshooting
Can I preview what pkill will affect?
Use pgrep with equivalent selection conditions and review the results. Processes may still change between inspection and signalling.
Why did more than one task stop?
All matches are signalled, not only the first. Use a verified individual PID when a single task should be affected.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man pkill.