Centos7 system recently played, or there are many ways to change with Centos6, where records about the method boot from the start of how to add scripts and services at Centos7.
1, add the boot from Kai Services
I'm here to docker services, for example, you can set the following two commands:
- 1
# systemctl enable docker.service #设置docker服务为自启动服务 相当于我们的 chkconfig docker on
- 2 # systemctl start docker.service # start docker Service
2, add the boot from Kai Script
Increase in centos7 script There are two common methods to script StartTomcat.sh example:
# / bin / bash! # the Description: boot from Kai script /usr/local/tomcat/bin/startup.sh # start tomcat
method one:
1, giving the script executable permissions (/opt/script/StartTomcat.sh your script path)
1
|
# chmod +x /opt/script/StartTomcat.sh
|
2, open the /etc/rc.d/rc.local file, add the following at the end of
echo "/opt/script/StartTomcat.sh" >> /etc/rc.d/rc.local
3, in the centos7, / etc / rc.d / rc.local permissions are reduced, it is necessary to execute the following commands impart executable permissions
chmod +x /etc/rc.d/rc.local
Method Two:
1, the script moves to the next directory /etc/rc.d/init.d
# mv /opt/script/StartTomcat.sh /etc/rc.d/init.d
2, increase the executable permissions script
chmod +x /etc/rc.d/init.d/StartTomcat.sh
3, add a script to automatically boot project
cd /etc/rc.d/init.d chkconfig --add StartTomcat.sh chkconfig StartTomcat.sh on
Quote from completely
Centos7 system recently played, or there are many ways to change with Centos6, where records about the method boot from the start of how to add scripts and services at Centos7.
1, add the boot from Kai Services
I'm here to docker services, for example, you can set the following two commands:
- 1
# systemctl enable docker.service #设置docker服务为自启动服务 相当于我们的 chkconfig docker on
- 2 # systemctl start docker.service # start docker Service
2, add the boot from Kai Script
Increase in centos7 script There are two common methods to script StartTomcat.sh example:
# / bin / bash! # the Description: boot from Kai script /usr/local/tomcat/bin/startup.sh # start tomcat
method one:
1, giving the script executable permissions (/opt/script/StartTomcat.sh your script path)
1
|
# chmod +x /opt/script/StartTomcat.sh
|
2, open the /etc/rc.d/rc.local file, add the following at the end of
echo "/opt/script/StartTomcat.sh" >> /etc/rc.d/rc.local
3, in the centos7, / etc / rc.d / rc.local permissions are reduced, it is necessary to execute the following commands impart executable permissions
chmod +x /etc/rc.d/rc.local
Method Two:
1, the script moves to the next directory /etc/rc.d/init.d
# mv /opt/script/StartTomcat.sh /etc/rc.d/init.d
2, increase the executable permissions script
chmod +x /etc/rc.d/init.d/StartTomcat.sh
3, add a script to automatically boot project
cd /etc/rc.d/init.d chkconfig --add StartTomcat.sh chkconfig StartTomcat.sh on