Upstart manages Ubuntu self-starting services (applicable after 10.04)

Source: Internet
Author: User

From Ubuntu 10.04, upstart is introduced into the processes and services started by the management system. So if you want to add or Disable Automatic startup of some service processes, the previous approach (such as using update-rc.d commands) will not work. If you run this command to stop MySQL, you will get the following information:

$>sudo /etc/init.d/mysql stopRather than invoking init scripts through /etc/init.d, use the service(8)utility, e.g. service mysql restart Since the script you are attempting to invoke has been converted to anUpstart job, you may also use the restart(8) utility, e.g. restart mysql

So how to use upstart?

First, we know that the old system management is called sysv, which controls the Automatic startup of the service by setting up scripts in the directory representing each run level. For example, scripts starting with S in the/etc/rc0.d directory will be run at runlevel 0. In this way, if you want to shield a service, you need to rename the one starting with S to start with K. Therefore, all scripts under rc *. D are linked to the/etc/init. d directory. Upstart adopts a completely different method. It requires all the startup scripts, which are actually configuration files created in the/etc/init directory. Each Service has a file that defines the running levels, conditions, and events of script startup and shutdown,. We can see that upstart is much better than sysv, because sysv starts linearly and sequentially. An S20 service must wait until S19 is started. If it takes a lot of time to start a service, even if the subsequent services are completely irrelevant, you must wait. In upstart, service startup is based on events and is parallel. As long as an event occurs, the service can be started concurrently. This method is undoubtedly much better, because it can take full advantage of the current multi-core features of the computer, greatly reducing the time required to start.

The following describes its configuration file and how to manage the startup and stop of a service/automatic process.

Enter the/etc/init directory to view all the configuration files. Open one of them and its structure is similar to the following:

# name - description## more details of the service# description     "description of the service" start on (local-filesystems  and net-device-up  and runlevel [45]stop on runlevel [06] expect daemontask emits event-1emits event-2... pre-start script... exec /usr/sbin/... post-start script...

The content is easy to understand. Start on and stop on define the startup and stop events and running levels. Emits is the event triggered by the service itself, that is, the event triggered after the service is started. The following pre-start scripts and post-START scripts are scripts run before and after startup. Is it easy?

So how to cancel Automatic Start of a service? Take MYSQL as an example. Just comment out the three lines of start on. But do not delete the/etc/init/MySQL. conf file, so that you can still use the start/stop commands to control its status.

Run start, stop, restart, and status to start, stop, and query the service status. Another useful command is initctl. You can enter initctl list on the command line to list the running statuses of all services. Man initctl can be used to obtain more information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.