Ubuntu (12.04) upstart (at boot) services

Creating your own ubuntu upstart service:

  • Create a shell script. (Name it whatever you want. Here I am assuming it to be “autorun.sh”)

    vi autorun.sh
    
  • Copy the shell script to /etc/init.d/

    sudo cp autorun.sh /etc/init.d/autorun.sh
    
  • Make the script executable.
    sudo chmod +x /etc/init.d/autorun.sh
    
  • Update the upstart table of ubuntu by creating symbolic links.

    sudo update-rc.d autorun.sh defaults
    
  • Done.

To boot an already existing script:

  • Update the upstart table of ubuntu by creating symbolic links.
    sudo update-rc.d service_name defaults
    
  • Enable a disabled upstart service
    sudo update-rc.d service_name enable
    

To remove a script from upstart:

  1. (option-1)
    update the table and remove the script(not necessary)

    sudo update-rc.d -f autorun.sh remove
    sudo rm /etc/init.d/autorun.sh (optional)
    
  2. (option-2)
    Disable the service from boot

    sudo update-rc.d -f autorun.sh disable
    
  3. (option-3)
    if there is a configuration file for the script in /etc/init/

    sudo echo 'manual' | /etc/init/scriptname.override
    sudo update-rc.d -f scriptname remove
    

Reference: ubuntu upstart cookbook

4 responses to “Ubuntu (12.04) upstart (at boot) services

    1. Upstart in simple language is basically an event-based service starter. service can be anything, from a daemon process like apache, mysql to any shell script you want.
      Here I am particularly talking abut the event when a system boots.

      1. upstart and update-rc.d are not the same thing.

        update-rc.d manages old-style sysvinit scripts.

        upstart is a completely different animal, with completely different rules. Ubuntu is slowly migrating from old-style sysvinit to upstart, but a lot of things still use the old system (like, regrettably, apache as installed from official repos), so there are both /etc/init.d and /etc/init in an Ubuntu install, and they are not the same at all.

        http://upstart.ubuntu.com/

  1. “sudo echo ‘manual’ | /etc/init/scriptname.override”

    won’t work, sudo does not traverse the pipe. You will need to use:

    echo ‘manual’ | sudo tee /etc/init/scriptname.override

Leave a Reply

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