I'm on an OpenVZ VPS and I created a background process as a non-root user then disowned it i.e.

user@server:~$node server.js &

I SSH'ed out of the VPS and now I'm back in but I can't seem to kill the process using its PID. Pkill 1292. It even fails as root. I know its not dead because when I run top its till running. Also, when I run ps -l -p 1292 I can see that the process is till running.

I can tell that the process is not attached to any terminal session because the ps command displays a Question Mark at TTY i.e.


How do I kill this process?

  • pkill is to kill processes based on their name. To kill based on pid, it's just kill. If kill 6806 (short for kill -s TERM 6806) fails, you can try kill -s KILL 6806 which would terminate it non-gracefully. – Stéphane Chazelas Mar 20 '18 at 15:51
  • Works! Thanks. Used to think pkill meant 'process kill' . Could you post it as an answer so I can mark it as the solution ? – Karanja Mutahi Mar 20 '18 at 15:54
  • unix.stackexchange.com/questions/8916/…; i am in the kill -9 <pid> camp – ron Mar 20 '18 at 16:10

pkill (like pgrep which uses the same interface, initially a Solaris command, now found on many other unix-likes including Linux (procps package)) is to kill processes based on their name.

pkill regexp

kills (sends the SIGTERM signal) to all the processes whose name¹ matches the given regular expression.

So here pkill node would kill all the processes whose name contains node. Use pkill -x node (-x like in grep/pgrep for exact match) to kill processes whose name is exactly node.

To kill based on pid², it's just kill (a command built in most shells so it can also be used on shell jobs, but also as a stand-alone utility).

If kill 6806 (short for kill -s TERM 6806) fails, you can as a last-resort try kill -s KILL 6806 which would terminate it non-gracefully.

¹ process name being a notion that varies a bit depending on the OS. On Linux, it's generally up to the first 15 bytes of the base name of the file that the process (or its closest ancestor) executed, though a process may change it to any arbitrary (but not longer than 15 bytes) value. See also pkill -f to match on the argument list.

² kill can also kill based on process group id. kill -- -123 sends the SIGTERM signal to all the processes whose process group id is 123. When using the job specification for the kill builtin of POSIX shells (as in kill %spec), kill generally also sends signals to a process group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.