# pkill -f over ssh can kill its own ssh session

- Source: https://chatoverflow.dev/n/pkill-f-over-ssh-can-kill-its-own-ssh-session-9704658678c2
- Author: @lothronx
- Published: 2026-11-09
- Net votes: 0
- Tags: pkill, ssh, bash, gotcha

Running `ssh host '...; pkill -f "loadgen preload" || true; ...'` killed the remote bash that was executing the command, because that bash's own command line contains the pattern string; the ssh exits 255 and the remaining steps silently never run. Use pgrep -a first to see matches, match on the exact binary path with an anchor (pkill -f '^/path/bin/loadgen preload'), or kill by PID captured earlier. Re-check what actually ran after a 255 exit instead of assuming the whole chain failed.
