[NTLUG:Discuss] How to stop process at system shutdown

Neil Aggarwal neil at JAMMConsulting.com
Wed Feb 14 23:08:26 CST 2001


Michael:

I am not looking at my screen.  My server is not local, so I am 
looking thru /var/log/messages.  

I see a message for when apache starts up:

Feb 14 22:58:16 neil235 httpd: Starting apache:
Feb 14 22:58:17 neil235 httpd: /usr/local/apache/bin/apachectl start:
httpd started

But, I dont see a similar message among the shutdown messages in
that file when the server shuts down for a reboot.

Here is exactly what I did:

First, I placed the following lines in a file /etc/rc.d/init.d/httpd:
#!/bin/sh
# Starts apache.
#
# Source function library.
. /etc/rc.d/init.d/functions

[ -f /usr/local/apache/bin/apachectl ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
        echo -n "Starting apache: "
        /usr/local/apache/bin/apachectl start
        RETVAL=$?
        ;;
  stop)
        echo -n "Shutting down apache: "
        /usr/local/apache/bin/apachectl stop
        echo
        RETVAL=$?
				echo_success()
        ;;
  status)
        /usr/local/apache/bin/apachectl status
        RETVAL=$?
        ;;
  restart)
        /usr/local/apache/bin/apachectl restart
        RETVAL=$?
        ;;
  *)
        echo "Usage: syslog {start|stop|status|restart}"
        exit 1
esac

exit $RETVAL

Next, I issued the following commands:
chmod +x /etc/init.d/httpd
rm -f /etc/rc3.d/S85httpd
rm -f /etc/rc0.d/K15httpd
rm -f /etc/rc6.d/K15httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc3.d/S85httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc0.d/K15httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc6.d/K15httpd

Finally, I rebooted the server:
	/sbin/reboot

I did check that I can run the commands manually
/etc/rc.d/init.d/httpd start
/etc/rc.d/init.d/httpd stop
Work as I intend them to do so.

I just dont understand why this is not working.  This makes
no sense to me.  The startup command is working.  I dont 
understand why the stop command is not -- it uses the same
file.

Thanks,
	Neil.

Michael Patrick wrote:
> 
> Neil,
> 
> As I understand this issue, you are looking for the green [OK] as your
> machine is going down.  You will not get that just using apachectl.  The
> status codes are written using the functions in /etc/rc.d/init.d/functions
> 
> In particular,
> 
> echo_success() {
>   [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
>   echo -n "[  "
>   [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
>   echo -n "OK"
>   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
>   echo -n "  ]"
>   echo -ne "\r"
>   return 0
> }
> 
> does the [OK].  All the init-scripts I've seen use the killproc function,
> which in turn calls echo_success().
> 
> Given time, I will try to test this theory this evening and let you know
> what I find.  I'd try it now, but I think work would frown on it.
> 
> Everyone else... if I'm on crack here, lemme know. :)
> 
> Michael
> 
> -----Original Message-----
> From: Neil Aggarwal <neil at jammconsulting.com>
> To: discuss at ntlug.org
> Date: Wed, 14 Feb 2001 16:26:46 -0600
> Subject: Re: [NTLUG:Discuss] How to stop process at system shutdown
> 
> > Greg:
> >
> > I did this:
> > rm -f /etc/rc3.d/S85httpd
> > rm -f /etc/rc0.d/K15httpd
> > rm -f /etc/rc6.d/K15httpd
> > ln -s /usr/local/apache/bin/apachectl /etc/rc3.d/S85httpd
> > ln -s /usr/local/apache/bin/apachectl /etc/rc0.d/K15httpd
> > ln -s /usr/local/apache/bin/apachectl /etc/rc6.d/K15httpd
> >
> > And I still dont get the httpd stopped message when I do
> > /sbin/reboot
> >
> > Any more ideas?
> >
> > Thanks,
> >       Neil.
> >
> >
> > "Gregory L. Camp" wrote:
> > >
> > > Neil,
> > >
> > > You shouldn't put the start/stop commands in the same rc?.d directory
> > (rc3.d
> > > in your example).  The stop command should be in rc0.d and rc6.d
> > instead.
> > >
> > > You enter rc0.d when you shutdown and halt (i.e. shutdown -h now),
> > and rc6.d
> > > when you shutdown and reboot (i.e. shutdown -r now).
> > >
> > > Greg
> > >
> > > > -----Original Message-----
> > > > From: Neil Aggarwal [mailto:neil at JAMMConsulting.com]
> > > > Sent: Tuesday, February 13, 2001 8:59 PM
> > > > To: North Texas Linux Users Group
> > > > Subject: [NTLUG:Discuss] How to stop process at system shutdown
> > > >
> > > >
> > > > Hello:
> > > >
> > > > I am using RedHat 7.0.
> > > >
> > > > I am trying to figure out how to get apache to stop and start
> > > > at system startup and shutdown.
> > > >
> > > > I installed apache 1.3.14 in /usr/local/apache.  It has a
> > > > SysV-type start and stop file in /usr/local/apache/bin/apachectl,
> > > > so I added these links:
> > > > ln -s /usr/local/apache/bin/apachectl /etc/rc3.d/S85httpd
> > > > ln -s /usr/local/apache/bin/apachectl /etc/rc3.d/K85httpd
> > > >
> > > > When I start the system I see a message that apache is
> > > > starting, but when I shutdown the system, I dont see a
> > > > message that apache is stopping.
> > > >
> > > > I added an echo statement to the stop case of the apachectl file,
> > > > but I dont get that message.
> > > >
> > > > Can someone guide me on this?
> > > > I am sure it is something simple, but I dont fully understand
> > > > the SysV stuff.
> > > >
> > > > Thanks,
> > > >       Neil.
> > > >
> > > > --
> > > > Neil Aggarwal
> > > > JAMM Consulting, Inc. -- (972) 612-6056,
> > http://www.JAMMConsulting.com
> > > > Custom Internet Development -- Java, JSP, servlets, databases
> > > > _______________________________________________
> > > > http://ntlug.org/mailman/listinfo/discuss
> > > >
> > > _______________________________________________
> > > http://ntlug.org/mailman/listinfo/discuss
> >
> > --
> > Neil Aggarwal
> > JAMM Consulting, Inc. -- (972) 612-6056, http://www.JAMMConsulting.com
> > Custom Internet Development -- Java, JSP, servlets, databases
> > _______________________________________________
> > http://ntlug.org/mailman/listinfo/discuss
> 
> _______________________________________________
> http://ntlug.org/mailman/listinfo/discuss

--
Neil Aggarwal
JAMM Consulting, Inc. -- (972) 612-6056, http://www.JAMMConsulting.com
Custom Internet Development -- Java, JSP, servlets, databases



More information about the Discuss mailing list