0

I am in situation where i want to kill a process if exist & restart the same. How to do it?

currently i am doing this

killall -9 inetd && /bin/inetd

If inetd is not running i get this

killall: /bin/inetd: no process killed

Even though inetd is not running i want the above command to be successful.

prashanth cm
  • 49
  • 1
  • 1
  • 4

1 Answers1

0

Use ;

killall -9 inetd; /bin/inetd
tbsalling
  • 4,477
  • 4
  • 30
  • 51
  • but if some issue happens with killall, it will go ahead with /bin/inetd. I dont want this to happen. i want it to be successful even if the particular process is not found. – prashanth cm Jan 18 '16 at 12:14
  • That is not possible: "killall returns a zero return code if at least one process has been killed for each listed command, or no commands were listed and at least one process matched the -u and -Z search criteria. killall returns non-zero otherwise." – tbsalling Jan 18 '16 at 12:52