Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to add boot startup service for centos7

Shulou Source: shulou.com Published: 2022-06-01 14:34:43 10月04日 Update

This article introduces the knowledge of "how to add boot startup service to centos7". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Add self-booting service

It is very convenient to add a self-starting service to centos7. You only need two commands (take Jenkins as an example):

Systemctl enable jenkins.service # set jenkins service to self-startup service sysstemctl start jenkins.service # start jenkins service

Second, add a boot script

There are two common ways to add scripts to centos7. Take the script autostart.sh as an example:

#! / bin/bash#description: boot script / usr/local/tomcat/bin/startup.sh # start tomcat

Method one

1. Give the script executable permissions (/ opt/script/autostart.sh is your script path)

Chmod + x / opt/script/autostart.sh

one

2. Open the / etc/rc.d/rc/local file and add the following at the end

/ opt/script/autostart.sh

3. In centos7, the permission of / etc/rc.d/rc.local is reduced, so you need to execute the following command to give it executable permission.

Chmod + x / etc/rc.d/rc.local

Method two

1. Move the script to / etc/rc.d/init.d directory

Mv / opt/script/autostart.sh / etc/rc.d/init.d

2. Increase the executable permissions of the script

Chmod + x / etc/rc.d/init.d/autostart.sh

3. Add a script to the startup project

Cd / etc/rc.d/init.dchkconfig-- this is the end of add autostart.shchkconfig autostart.sh on's "how to add Boot Startup Service to centos7". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Scripts services permissions content methods commands more knowledge practicality learning next dilemma practice common use situation files articles end case directory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Docker macOS Linux