CentOS 7 System Add Startup item

Source: Internet
Author: User

The CentOS 7 system has replaced the CentOS 6 RunLevel system service Management with SYSTEMD. Adding a startup item under/ETC/RC[0-6S].D cannot be performed automatically when the system starts, and you need to add a startup item through the new Systemd.unit configuration.

SYSTEMD Features

1. You can specify dependencies between the unit

2. You can control the order of execution between the unit or allow them to execute concurrently

A simple example

The function of this example is to configure a startup item via SYSTEMD

1. Create a file Myservice.service in the/usr/lib/systemd/system directory with the following contents:

[Unit] DESCRIPTION=SYSTEMD Unit demo[service]execstart=/your/path/startup.shexecstop=/your/path/ Shutdown.shremainafterexit=yes[install]wantedby=default.target

The Execstart entry specifies the command that the MyService unit executes at startup, which can be used to perform an operation or to start a service. The Execstop entry specifies the command that the MyService unit executes when it is closed, which can be used to perform some cleanup operations or to shut down the service.

2. Execute the command "SYSTEMCTL enable MyService" Enabling the startup item

3. Execute the command "systemctl start MyService" To activate the startup item

So far, MyService has been started and will be executed automatically after the next system boot.

There are several types of systemd.unit that correspond to different behaviors. The above example shows only the most basic usage of the Unit of service type, the detailed SYSTEMD function and configuration can refer to Systemd's manpage documentation.

CentOS 7 System Add Startup item

Related Article

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.