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

[ad#ad-post-1]

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

[ad#post-image]

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

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

Comments

comments

Tagged on:         

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

  • March 1, 2012 at 4:45 am
    Permalink

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

  • July 18, 2013 at 3:44 am
    Permalink

    Good way of describing, and pleasant post to get data concerning my presentation focus,
    which i am going to present in institution of higher education.

Comments are closed.