LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-04-2009, 02:02 PM   #1
gxgtudor
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Rep: Reputation: Disabled
Informix start/stop along with redhat start/stop


Hi all,

I'm trying to start/stop Informix along with my linux os start/stop.
For this I've made a test script in order to test this but I'm facing a problem. The service is starting along with the system but when I'm stopping (rebooting) the system it doesn't run the "K10test" script.

root@rhl5 ~# cd /etc/init.d/
root@rhl5 init.d# cat test
#!/bin/sh
#
# Init file for test server daemon
#
# chkconfig: 345 99 10
# description: test server daemon
#
# processname: test
#
start()
{
echo "Start test script at `date`" >> /root/test.log
sleep 3
}

stop()
{
echo "Stop test script at `date`" >> /root/test.log
sleep 3
}

case $1 in
start)
start
;;
stop)
stop
;;
esac
root@rhl5 init.d#
root@rhl5 init.d# chkconfig test --add
root@rhl5 init.d# chkconfig test --list
test 0 : off 1: off 2: off 3: on 4: on 5: on 6: off
root@rhl5 etc# for i in 0 1 2 3 4 5 6; do ls rc$i.d/*test*;done
rc0.d/K10test
rc1.d/K10test
rc2.d/K10test
rc3.d/S99test
rc4.d/S99test
rc5.d/S99test
rc6.d/K10test

root@rhl5 init.d#

After sistem reboot you can see that the /etc/init.d/test stop is not executed.

root@rhl5 init.d # cat /root/test.log
Start test script at Mon Feb 9 07:30:19 EET 2009
Start test script at Mon Feb 9 07:50:16 EET 2009


Can you please tell what I'm missing?

Thanks
 
Old 03-05-2009, 10:38 AM   #2
healyma
Member
 
Registered: Feb 2009
Location: Mayo, Ireland
Distribution: LFS 6.4; Debian 5.4; Mythbuntu & Kubuntu 10.04
Posts: 49

Rep: Reputation: 19
Hi,
Can you switch between run-levels 3 and 2 (or 5 and 2) and see if the script runs as expected - also, does it run on shutdown as opposed to reboot

Mark
 
Old 03-06-2009, 02:13 AM   #3
gxgtudor
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi,

I've figured out what I was missing.

In my script I should create a file in the path: /var/lock/subsys/<service name>, in ma case the script should look like:

#!/bin/sh
#
# Init file for test server daemon
#
# chkconfig: 345 99 10
# description: test server daemon
#
# processname: test
#
start()
{
echo "Start test script at `date`" >> /root/test.log
touch /var/lock/subsys/test
sleep 3
}

stop()
{
echo "Stop test script at `date`" >> /root/test.log
rm -f /var/lock/subsys/test
sleep 3
}

case $1 in
start)
start
;;
stop)
stop
;;
esac

The idea is that the system looks in this directory in order to know which services to stop. And if it doesn't find a lock file it will not try to stop it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 06:17 AM
Computer doesn't start; fans start then stop; 1 long, 1 short beep PatrickMay16 General 18 09-26-2007 07:48 PM
start|stop redhat style kamtono Linux - General 4 06-02-2005 10:26 AM
stop/start firewall matt1982 Debian 6 11-12-2004 07:17 AM
Start/stop services on start-up koyi Slackware 5 08-04-2003 08:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration