Dress applications startup order at boot

Asked by Vianney

This is my server setup:

OS: Ubuntu Server 10.10
PC: Intel Dual Core/4GB RAM
LAMP (Installed during the OS installation)

I'm a newbie to Ubuntu/Linux, and probably this question was answered before.

I have a web application which uses a MySQL Database to authenticate the users. This application automatically starts at the system Startup (I confirmed that it actually runs) and apparently it is starting to run before Apache/MYSQL, so only if I restart the application the users are able to get authenticated against the database.

My question is: how can I change the startup order on Ubuntu Server 10.10?


Question information

English Edit question
Ubuntu mysql-dfsg-5.1 Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Vianney (vianneyjs) said :

....meaning the startup order of the applications, so my application starts after Apache/MySQL startup.

Revision history for this message
actionparsnip (andrew-woodhead666) said :

I suggest you make a script. Take the item out of the regular startup items. The script will contain 3 lines:

sleep 30
foo &

Replace foo with the command to start the service. The script can be added to the startup by adding it /etc/rc.local above the exit 0 line. This will make the service wait 30 seconds then run. Be sure to add the ampersand character or your boot will never complete.

It's a bit of a hack but will work. You can use the same script to add more items if you want to delay their execution so it is genuinely good to do.

Revision history for this message
Vianney (vianneyjs) said :

Thanks for your promt response actionparsnip.

What do you mean by taking out the item from the regular startup items, remove the executable application from /etc/init.d ?

Where should a relocate the executable application?

Would it something like this?

sleep 30
app01 &
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

exit 0

Thanks a lot.

Revision history for this message
actionparsnip (andrew-woodhead666) said :


sudo nano /usr/bin/delayedapps

Add the 3 lines I described, then press CTRL+X, press Y, press ENTEr

Then run:
sudo chmod +x /usr/bin/delayedapps

You now have a script. Then run:
sudo nano /etc/rc.local

Delete the lines you add and change them for the word:

Press CTRL+X, press Y, press ENTER.

(If yo made a script called app01 and it is in /usr/bin then just delete #!/bin/bash and the sleep line from /etc/rc.local and add the sleep line to app01.

You will need to look online to see how to remove the current startup item. I believe bum will give a text based GUI but you need a single command revolving around rc.update to remove the startup item so you can manually start it using your script.

Revision history for this message
Vianney (vianneyjs) said :

Sounds complicated, but I will try my best.

Thanks for your help.