Bash – How to kill a process after detaching it from bash

bashjob-controlkillprocess

I have multiple scripts that detach a process from bash using nohup and &>/dev/null &. My question is, how do I kill the process after completely detaching it from bash. using killall or pidof ScriptName doesn't work.

Best Answer

nohup should only affect the hangup signal. So kill should still work normally. Maybe you are using the wrong pid or process name; compare with pstree -p or ps -ef.

If you still suspect nohup, maybe you could try disown instead.

$ sleep 1000 &
$ jobs -p
13561
$ disown
$ jobs -p
$ pidof sleep
13561
$ kill 13561
$ pidof sleep
$
Related Question