Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to write the boot service script of cenetOS system

Shulou Source: shulou.com Published: 2022-06-01 03:33:38 10月31日 Update

CenetOS system boot service script how to write, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

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 # launch tomcat

Method one

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

Chmod + x / opt/script/autostart.sh

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.d

Chkconfig-add autostart.sh

Chkconfig autostart.sh on

After reading the above, have you mastered the method of how to write the startup service script of cenetOS system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Scripts methods permissions content systems services more problems helpless for this reason command response common use skills files endings directories articles experience Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Shulou Information macOS MariaDB