I'm Aoddy.

If you lose yourself, you lose everything. — Michael Scofield

How to start a script by root permission at boot time on Ubuntu server 8.10.

by aoddy on March 2, 2009

Today my Opmanger server is down, I start it again but my service doesn’t start by automatic at boot time. So I need to start it by root permission at startup time. And this is my solution.

1. Write your script for start a service

#!/bin/bash
echo "Start my service!!!";
cd /path/of/my/script/
./run_my_script.sh

2. Change a permission file to execute

$ cd /path/of/my/script/
$ sudo chmod +x run_my_script.sh

3. Create a symbolic link file into /etc/init.d/

$ sudo ln -s /path/of/my/script/run_my_script.sh /etc/init.d/run_my_script.sh

4. Add this script into start up time

$ sudo update-rc.d run_my_script.sh defaults
update-rc.d: warning: /etc/init.d/run_my_script.sh missing LSB style header
 Adding system startup for /etc/init.d/run_my_script.sh ...
   /etc/rc0.d/K20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc1.d/K20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc6.d/K20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc2.d/S20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc3.d/S20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc4.d/S20run_my_script.sh -> ../init.d/run_my_script.sh
   /etc/rc5.d/S20run_my_script.sh -> ../init.d/run_my_script.sh

5. Test by restart your server and check this process by ps -ef | grep run_my_script.sh

$ ps -ef | grep run_my_script.sh

Thanks for original : http://www.ubuntu-howto.info/howto/how-to-execute-a-command-program-or-script-at-startup-init-mini-howto

Related Posts

3 thoughts on “How to start a script by root permission at boot time on Ubuntu server 8.10.

  1. mhf says:

    Thanks a lot !!! I’ll keep it in mind. Very usefull.

  2. Thank you, I have recently been looking for info approximately this topic for a long time
    and yours is the greatest I’ve found out till now. However, what about the bottom line? Are you positive concerning the source?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">