How to shield the kill output [duplicate]
This can be done using 'wait' + redirection of wait to /dev/null :
sleep 2 &PID=$!kill -9 $PIDwait $PID 2>/dev/nullsleep 2sleep 2sleep 2
This script will not give the "killed" message:
-bash-4.1$ ./test-bash-4.1$
While, if you try to use something like:
sleep 2 &PID=$!kill -9 $PID 2>/dev/nullsleep 2sleep 2sleep 2
It will output the message:
-bash-4.1$ ./test./test: line 4: 5520 Killed sleep 2-bash-4.1$
I like this solution much more than using 'disown' which may have other implications.
Idea source: https://stackoverflow.com/a/5722850/1208218