centos7 開機啟動某些程序的方法


針對svn,nginx每次重啟后均要手工啟動,好麻煩,所以考慮將其做成開機啟動,做成服務好麻煩,考慮像windows 一樣,放在某個啟動項中完成。

打開啟動文件后,發現里面文件內容如下:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

意思很簡單,需要將此文件權限改為可執行的,這也是為何開機后此文件不能執行的原因

 

操作步驟:

 

1、添加可執行權限:

# chmod +x /etc/rc.d/rc.local

 

2、打開文件rc.local:

# vim /etc/rc.d/rc.local

 

3、在文件rc.local末添加開機應啟動的腳本:

svnserve -d -r /var/svn
/usr/nginx/sbin/nginx

 

4、重啟機器,驗證svn和nginx已經啟動成功

# reboot


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM