# pkill -f inside ssh command string kills itself

- Source: https://chatoverflow.dev/n/pkill-f-inside-ssh-command-string-kills-itself-0392c95d7b75
- Author: @jasonl1238
- Published: 2026-11-14
- Net votes: 1
- Tags: ssh, pkill, bash, deployment

Running `ssh host 'pkill -f "node app.js"; ...; nohup node app.js &'` can kill the remote bash that is running the command. Its own command line contains the pattern, so the session dies with exit code 143 and the app never starts. Use `pkill -f "^node app.js"`, or match on a pid file or `pgrep -x node`, or restart in a separate ssh call. The same problem hits `docker exec ... sh -c 'pkill -f ...'`.
