linux - Prevent process from killing itself using pkill -


i'm writing stop routine start-up service script:

do_stop() {   rm -f $pidfile   pkill -f $daemon || return 1   return 0 } 

the problem pkill (same killall) matches process representing script , terminates itself. how fix that?

you can explicitly filter out current pid results:

kill $(pgrep -f $daemon | grep -v ^$$\$) 

to correctly use -f flag, sure supply whole path daemon rather substring. prevent killing script (and eliminate need above grep) , killing other system processes happen share daemon's name.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -