【centos7】添加开机启动服务/脚本
生活随笔
收集整理的這篇文章主要介紹了
【centos7】添加开机启动服务/脚本
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
一、添加開機自啟服務
在centos7中添加開機自啟服務非常方便,只需要兩條命令(以Jenkins為例):
systemctl enable jenkins.service #設置jenkins服務為自啟動服務 sysstemctl start jenkins.service #啟動jenkins服務二、添加開機自啟腳本
在centos7中增加腳本有兩種常用的方法,以腳本autostart.sh為例:
#!/bin/bash #description:開機自啟腳本 /usr/local/tomcat/bin/startup.sh #啟動tomcat方法一
1、賦予腳本可執行權限(/opt/script/autostart.sh是你的腳本路徑)
chmod +x /opt/script/autostart.sh2、打開/etc/rc.d/rc/local文件,在末尾增加如下內容
/opt/script/autostart.sh3、在centos7中,/etc/rc.d/rc.local的權限被降低了,所以需要執行如下命令賦予其可執行權限
chmod +x /etc/rc.d/rc.local方法二
1、將腳本移動到/etc/rc.d/init.d目錄下
mv /opt/script/autostart.sh /etc/rc.d/init.d2、增加腳本的可執行權限
chmod +x /etc/rc.d/init.d/autostart.sh3、添加腳本到開機自動啟動項目中
cd /etc/rc.d/init.d chkconfig --add autostart.sh chkconfig autostart.sh on以上兩種方法均已在centos7系統上驗證過,如有疑問,歡迎大家評論留言.
轉載于:https://my.oschina.net/xiaoxiezi/blog/3009499
總結
以上是生活随笔為你收集整理的【centos7】添加开机启动服务/脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [idea] - 项目启动报错Proce
- 下一篇: Data Vault的一点思考(二)