新聞中心
本篇內(nèi)容介紹了“centos7怎么添加開(kāi)機(jī)啟動(dòng)服務(wù)”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
一、添加開(kāi)機(jī)自啟服務(wù)
在centos7中添加開(kāi)機(jī)自啟服務(wù)非常方便,只需要兩條命令(以Jenkins為例):
systemctl enable jenkins.service #設(shè)置jenkins服務(wù)為自啟動(dòng)服務(wù) sysstemctl start jenkins.service #啟動(dòng)jenkins服務(wù)
二、添加開(kāi)機(jī)自啟腳本
在centos7中增加腳本有兩種常用的方法,以腳本autostart.sh為例:
#!/bin/bash #description:開(kāi)機(jī)自啟腳本 /usr/local/tomcat/bin/startup.sh #啟動(dòng)tomcat
方法一
1、賦予腳本可執(zhí)行權(quán)限(/opt/script/autostart.sh是你的腳本路徑)
chmod +x /opt/script/autostart.sh
1
2、打開(kāi)/etc/rc.d/rc/local文件,在末尾增加如下內(nèi)容
/opt/script/autostart.sh
3、在centos7中,/etc/rc.d/rc.local的權(quán)限被降低了,所以需要執(zhí)行如下命令賦予其可執(zhí)行權(quán)限
chmod +x /etc/rc.d/rc.local
方法二
1、將腳本移動(dòng)到/etc/rc.d/init.d目錄下
mv /opt/script/autostart.sh /etc/rc.d/init.d
2、增加腳本的可執(zhí)行權(quán)限
chmod +x /etc/rc.d/init.d/autostart.sh
3、添加腳本到開(kāi)機(jī)自動(dòng)啟動(dòng)項(xiàng)目中
cd /etc/rc.d/init.d chkconfig --add autostart.sh chkconfig autostart.sh on
“centos7怎么添加開(kāi)機(jī)啟動(dòng)服務(wù)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
網(wǎng)站標(biāo)題:centos7怎么添加開(kāi)機(jī)啟動(dòng)服務(wù)-創(chuàng)新互聯(lián)
新聞來(lái)源:http://www.dlmjj.cn/article/cchcjh.html