LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2010, 09:05 AM   #1
jgonsalves
LQ Newbie
 
Registered: May 2010
Posts: 8

Rep: Reputation: 0
service won't start at boot


I have a service/daemon that won't start from boot.
I have used the chkconfig --add <script name> command that went ok
I also used the chkconfig <script name> on and that seems to be fine and I have made the script executable Chmod 777 <filename>. By all account it looks like the script is running at boot the the services has not started. When I do a ps -ef | grep ndb_mgmd this process is no there. the script can be run from the console and sems to run fine! can anyone shed some light on this. here is my script.

#!/bin/bash
# chkconfig: 345 70 30
# description: MySQL Cluster management server start/stop script
echo hello Paul >> /tmp/hello.txt
configdir=/var/lib/mysql-cluster/
configini=$configdir/config.ini
managementnodeid=1
portnumber=1186
initial=

STARTMGM="/usr/sbin/ndb_mgmd -f $configini --ndb-nodeid=$managementnodeid $initial --configdir=$configdir"

start() {
$STARTMGM
echo start >> /tmp/hello.txt
}

stop() {
ndb_mgm -c host=127.0.0.1:$portnumber -e "$managementnodeid stop"
echo stop >> /tmp/hello.txt
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
 
Old 05-25-2010, 11:44 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
Try putting your external commands in brackets :

ie.

Code:
start() {
$(/usr/sbin/ndb_mgmd -f "$configini --ndb-nodeid=$managementnodeid $initial --configdir=$configdir")
echo start >> /tmp/hello.txt
}
You can't call a variable like a function, so
Code:
start() {
$STARTMGM
echo start >> /tmp/hello.txt
}
won't work.

AFAIK, you have to double quote variables to expand them into their contents, so configini=$configdir/config.ini is probably not being defined properly either.

http://tldp.org/LDP/abs/html/

Last edited by smoker; 05-25-2010 at 11:48 AM.
 
Old 05-25-2010, 12:26 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Hey smoker! What you been smoking?!

The /usr/sbin/ndb_mgmd command will run just fine without a surrounding $( ) and will not run with its arguments enclosed in double quotes as in "$configini --ndb-nodeid=$managementnodeid $initial --configdir=$configdir" because that will pass a single argument instead of several words.

And there is no need to double quote variables to expand them into their contents. If they contain embedded whitespace it may be necessary to avoid them being split into words at the whitespace but not when they are on the RHS of an assignment as in configini=$configdir/config.ini. It would work as configini="$configdir/config.ini" but such double quoting is not necessary.

@jgonsalves: IDK the ndb_mgm command but "$managementnodeid stop" is unusual; does it really need to be a single word? Should it not be "$managementnodeid" stop ? If so it's surprising that the script works when "run from the console". Are you 100% sure it works then?
 
Old 05-26-2010, 06:52 AM   #4
jgonsalves
LQ Newbie
 
Registered: May 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for the replies Guys but none of your suggestions worked. This script was copied from a duplicate server that seems to work fine and I can start and stop the script from the console. Iam running this on a Fedora 11 build. although I do think it's something to do with the script.

Last edited by jgonsalves; 05-26-2010 at 06:55 AM. Reason: add more info
 
Old 05-26-2010, 07:20 AM   #5
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Quote:
although I do think it's something to do with the script.
Can you run the script from the terminal and post the output?
 
Old 05-26-2010, 07:29 AM   #6
jgonsalves
LQ Newbie
 
Registered: May 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Run with the start call
[root@UKLX-PRMGM ~]# /etc/init.d/ndb_mgmd start
2010-05-26 13:20:32 [MgmtSrvr] INFO -- NDB Cluster Management Server. mysql-5.1.39 ndb-7.0.9b
2010-05-26 13:20:32 [MgmtSrvr] INFO -- Loaded config from '/etc/mysql/ndb_1_config.bin.1'
[root@UKLX-PRMGM ~]#

Run with the stop call
[root@UKLX-PRMGM ~]# /etc/init.d/ndb_mgmd stop
Connected to Management Server at: 127.0.0.1:1186
Node 1 has shutdown.
Disconnecting to allow Management Server to shutdown

it all seems to working fine from the console but won't start up from boot

Last edited by jgonsalves; 05-26-2010 at 07:31 AM. Reason: extr info
 
Old 05-26-2010, 08:07 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by jgonsalves View Post
Thanks for the replies Guys but none of your suggestions worked. This script was copied from a duplicate server that seems to work fine and I can start and stop the script from the console. Iam running this on a Fedora 11 build. although I do think it's something to do with the script.
OK.

When you write "it looks like the script is running at boot", what happens? Presumably /tmp/hello.txt is populated with "hello Paul" and "start" -- and you are confident those were written during boot, not during some previous testing (might be helpful to add /usr/bin/date >> /tmp/hello.txt before echo hello Paul >> /tmp/hello.txt).

In which case, if you get "start" in /tmp/hello.txt you are confident that the start function has run. The only effective line in the start function is $STARTMGM so we can focus on that. Perhaps that has a different value when run as a boot script and when run interactively (it's hard to see how but we've nothing else to work on). If not there is something about the process environment which the command runs in which is different.

How about adding some debugging to the start function?
Code:
for word in $STARTMGM
do
    echo "'$word'" >> /tmp/hello.txt
done
env >> /tmp/hello.txt
$STARTMGM &>> /tmp/hello.txt
/usr/bin/ps -ef | /usr/bin/grep -v grep | /usr/bin/grep ndb_mgmd >> /tmp/hello.txt
Then you could remove /tmp/hello.txt, run the script from a command line, rename /tmp/hello.txt, boot and then compare the new /tmp/hello.txt with the renamed one.
 
Old 05-26-2010, 08:12 AM   #8
jgonsalves
LQ Newbie
 
Registered: May 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I2010-05-26 13:07:19 [MgmtSrvr] INFO -- NDB Cluster Management Server. mysql-5.1.39 ndb-7.0.9b
2010-05-26 13:07:19 [MgmtSrvr] INFO -- Loaded config from '/etc/mysql/ndb_1_config.bin.1'
2010-05-26 13:07:19 [MgmtSrvr] ERROR -- The hostname this node should have according to the configuration does not match a local interface. Attempt to bind '192.168.202.232' failed with error: 99 'Cannot assign requested address' think I have found the problem I had A look in the boot log and found this:

I will try to put a sllep command in the csript to allow the ipaddress to be configured. unless you can give me a better alternative.
 
Old 05-26-2010, 08:39 AM   #9
jgonsalves
LQ Newbie
 
Registered: May 2010
Posts: 8

Original Poster
Rep: Reputation: 0
-solved

Thanks for your help chaps I have put a 5 second sleep command in the script giving the system time to get an IP address and the process now come up at boot.
 
Old 05-26-2010, 08:42 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Putting a sleep in the script will certainly delay the boot and will not fix the problem if the boot script that sets up the IP requirements runs after this one.

You could change the # chkconfig: 345 70 30 line to # chkconfig: 345 98 01 (I think that is the right way round for a late start and early finish) and then run chkconfig to remove the old and run it again to add the new. With a bit of luck that will result in the script running late enough in the boot process for the IP to have been configured.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to start a service at boot time. swamprat Linux - Newbie 4 07-03-2009 01:03 PM
How to get service to start at boot zaichik Linux - Newbie 12 08-27-2008 09:15 PM
BOINC as a service to start at boot purelithium Linux - General 14 11-18-2005 09:04 PM
how to start a service at boot senthilkumar Slackware 2 07-19-2004 07:33 AM
start the service for every boot time yuva_mca Linux - General 3 03-09-2004 01:18 PM


All times are GMT -5. The time now is 04:07 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration