LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   init script won't run at log-off (http://www.linuxquestions.org/questions/linux-newbie-8/init-script-wont-run-at-log-off-109794/)

dimangi 10-29-2003 02:18 AM

init script won't run at log-off
 
My script @ /etc/init.d doesn't run when I log off. It works fine at logon.

I have made a script, which is supposed to upload my current ip-address and online-status to a static www-server. This way I'd have a www-server running any time my comp is on, but the link inside would disappear when I log off.

There are 2 scripts: "httpstart.sh" and "httpstop.sh", and they are supposed to be run when the runlevel changes to 5. Both scripts work manually: "/sbin service wwwserv {stop|start}" and from the graphical services tool.

I have put a script "wwwserv" to /etc/init.d/, and ran "chkconfig --add wwwserv" + "chkconfig --level 5 wwwserv on". I have also checked /etc/rcN.d/ directories, and they have the right links there (K05wwwserv @ /rc6.d/).

Here is the "wwwserv" script:
-----------------------------------------------------------
#!/bin/sh
# chkconfig: - 99 5
# description: running a simple script at boottime
# processname: wwwserv
# /etc/sysconfig/httpstart.sh
# /etc/sysconfig/httpstop.sh
##################################################

case "$1" in
start)
echo -n "Starting wwwserv: "
/etc/sysconfig/httpstart.sh
echo
;;
stop)
echo -n "Stopping wwwserv: "
/etc/sysconfig/httpstop.sh
echo
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: wwwserv {start|stop|restart}"
exit 1
esac

exit 0
-------------------------------------------------------------

There is nothing done when i turn off the computer, and I didn't fnd any errors from /var/log/messages (starting the service seems to work fine).

I'm running rh9.0 with adsl.

Any suggestions, or more info needed?? :newbie:

kris.kj.jacobs 10-29-2003 03:19 AM

Have seen this on Redhat Linux 6 and 9.

The standard init scripts create an empty file in some directory at startup (/var/run, /var/lock, /var/subsys, ...).

At shutdown the system checks for this file before it starts the script at shutdown.

Check /etc/rc.sysinit to see how this works.


All times are GMT -5. The time now is 06:33 AM.