Search This Blog

Monday 19 December 2016

Procedure to add script in Ubuntu Run level

​To enable script in  ubuntu run level.

Terms:

  • /etc/init is where the upstart init configs live. While they are not scripts themselves, they essentially execute whatever is required to replace sysvinit scripts.

  • /etc/init.d is where all the traditional sysvinit scripts and the backward compatible scripts for upstart live. The backward compatible scripts basically run service myservice start instead of doing anything themselves. Some just show a notice to use the "service" command.

  • /etc/init/rc-sysinit.conf controls execution of traditional scripts added manually or with update-rc.d to traditional runlevels in /etc/rc*

  • /etc/default has configuration files allowing you to control the behaviour of both traditional sysvinit scripts and new upstart configs.

Using Services

Starting a Service

# Traditional:  /etc/init.d/myservice start  # Upstart  service myservice start

Stopping a Service

# Traditional:   /etc/init.d/myservice stop  # Upstart  service myservice stop

Getting a list of Services

# Traditional:  ls /etc/init.d  # Upstart:   service --status-all
  • Note: Upstart method will show both traditional and upstart services.

Adding a Service to Default runlevels

# Traditional  update-rc.d apache2 defaults    Upstart: there is no concept of runlevels, everything is event driven with dependencies. You would add an upstart config to /etc/init and potentially source a config file in /etc/default to allow users to override default behaviour. 

Removing a Service from Default runlevels

# Traditional - Something along the lines of  rm /etc/rc*/*myscript    Upstart: If no config is available in /etc/default, edit config in /etc/init

No comments:

Post a Comment