[CentOS] System V Init Script

James Bensley jwbensley at gmail.com
Wed Jun 3 10:26:53 UTC 2009


As you spotted john my killing loop was killing the system V script itself
also hence it never starting my_app again, so instead a simple if skips the
process ID of the system V script itself so it can continue on to start
my_app again:


> >       I'd think that the pgrep is matching both the processes you want
> >       to kill _and_ the init.d script itself.
>

My script looks like the following:


restart)
echo "Stopping my_app:"
pgrep my_app | while read PIDS
do
        if [ "$PIDS" -eq $$ ]; then
                continue
        fi
        kill -9 $PIDS
done
echo "Starting my_app:"
/etc/init.d/my_app start &
exit $?
;;

Thanks for the help everyone its greatly appreciated.

Regards,
James ;)


-----BEGIN GEEK CODE BLOCK-----
 Version: 3.1
GIT/MU/U dpu s: a--> C++>$ U+> L++> B-> P+> E?> W+++>$ N K W++ O M++>$ V-
PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+> DI D+++ G+ e(+++++) h--(++) r++ z++
------END GEEK CODE BLOCK------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20090603/bec34d6b/attachment.html>


More information about the CentOS mailing list