Karl Karl - 2 years ago 110
Linux Question

How can i have exit status of zero with kill command

I am using this command to kill

ps aux | bla bla | xargs kill -9

It's working fine but the problem is it also sometimes tries to kill subprocess id which already got killed because of parent process kill so it returns as non zero exit status.

Is there any way to make as exit status 0?

Answer Source

The trivial way is to just ignore any non-zero exit status:

ps aux | bla bal | xargs kill || true

(You probably shouldn't be using kill -9; it's a debugging tool, not intended for production use.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download