Kill Processes by Pattern with pkill

Signal every process whose name matches a pattern in one command, with an optional custom signal.

macOSProcessesTerminalHigh risk
Run pkill "Safari" to terminate all matching processes, or pkill -f "python script.py" to match the full command line.

01Command

Command
$ pkill "<pattern>"

02What it does

pkill combines pattern lookup and signalling in a single step: it finds every process whose name matches the pattern and sends each one the default TERM signal, so well-behaved apps exit cleanly. Pass a signal before the pattern (for example pkill -9 Safari) to send SIGKILL instead. Unlike killall, which matches exact process names, pkill matches partial names and regular expressions; the -f option widens matching to the entire command line.

03Risk

RiskHigh risk
!Warning: pkill -f matches substrings of the whole command line, so a broad pattern can kill processes you did not intend — an editor holding a file open named like your target, or a shell script with the keyword in its arguments. Run pgrep -fl with the same pattern first to preview exactly what would be signalled.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • PKILL Command: Kill processes in macOS
    SS64 · technical · 2026-09-17
    Evidence: The synopsis shows "pkill [- signal] [-ILafilnovx] ... pattern" and documents "-f Match against full argument lists. The default is to match against process names."
  • pkill(1) man page
    manpagez.com · technical · 2026-09-17
    Evidence: The page documents the pkill synopsis with an optional signal and the -f flag ("Match against full argument lists. The default is to match against process names"), plus -I to request confirmation before signalling each process.

Last verified: 2026-09-19 · Category: System & Settings

06Related solutions