Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a conflict with two programs in Ubuntu 10.04.

I have configured an init.d file that boots up a program. However, this program requires MySQL to be running before it starts. When I boot the machine, it's obvious that this script is being executed before MySQL has booted successfully.

I'm pretty inexperienced with Ubuntu's booting sequences and run levels. How can I make sure that MySQL is running before my init.d script is executed? I have heard that MySQL uses an alternative method of booting to init.d so I'm not sure how to go about this.

Thanks!

share|improve this question
    
By the way: you could also have your script start mysql at boottime and not let mysql start itself during boot ;) –  Rinzwind Jun 2 '12 at 18:52

1 Answer 1

up vote 2 down vote accepted

10.04 came with the new upstart system.

Here is an example of a start/stop mysql upstart: http://karlssonondatabases.blogspot.nl/2010/12/ubunto-upstart-for-automatic-mysql.html

Have a look at the start on part:

#
# MySQL Service for Recorded Future
#
description     "MySQL Server"
author          "Anders Karlsson, Recorded Future"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])
stop on runlevel [016]

expect fork
kill timeout 2
...

This tells the system that mysql has to start when this is true:

net-device-up
      and local-filesystems
      and runlevel [2345])

and has to stop when this is true:

runlevel [016]

So what you can do is create an upstart script for your program based on thise example and include a start on mysql telling it to start after mysql has started.


More info on upstart:

share|improve this answer
    
Thanks for your answer. In the script stanza is it possible to execute a bash script located in /etc/scripts/? Would the exec statement work with a bash script? –  Kieran Jun 2 '12 at 19:08
1  
@kieran yes ofcourse. You just use the whole path with the script name to execute it. –  Rinzwind Jun 2 '12 at 19:13
    
Thanks for your help! Solved it with a start on started mysql upstart job. –  Kieran Jun 2 '12 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.