Bash – Why can’t I pgrep a process

bashlinux

$ ps aux | grep -i ssh
USER      4364  0.0  0.0   9004  1032 ?        Ss   12:20   0:00 ssh -v -fND localhost:4000 USERNAME@SERVER-IP-ADDRESS

$ pgrep localhost:4000

Why doesn't this work?

Best Answer

By default, pgrep(1) will only match against the process name. If you want to match against the full command line, use the -f option:

$ pgrep -f localhost:4000
Related Question