Linux – How to let ‘kill’ ignore processes that are not alive

killlinux

How to tell the kill command to ignore processes if that process is not alive?

For example: 3453 is an alive process but 44534 is not.

kill -9 3453 44534

Best Answer

for pid in 3453 44534
do
  kill -9 "$pid" > /dev/null 2> /dev/null || :
done
Related Question