Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the boot service script of cenetOS system

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report