Linux下設置svn開機自啟動


方式一:centos 7 設置svn開機自啟動 使用新的systemctl 服務命令  (筆者成功驗證過,該方式可行)
[html] view plain copy
  1. [root@iZjvr37lpviqbkZ init.d]# vi /lib/systemd/system/svnserve.service  
  2. [root@iZjvr37lpviqbkZ init.d]# vi /etc/sysconfig/svnserve  
  3. [root@iZjvr37lpviqbkZ init.d]# systemctl enable svnserve.service  
  4. Created symlink from /etc/systemd/system/multi-user.target.wants/svnserve.service to /usr/lib/systemd/system/svnserve.service.  


安裝好 svn 服務后,默認是沒有隨系統啟動自動啟動的, CentOS 7 的 /etc/rc.d/rc.local 是沒有執行權限的, 系統建議創建 systemd service 啟動服務

於是查看 systemd 里 svn 的配置文件 /lib/systemd/system/svnserve.service

[plain]  view plain  copy
 
  1. [Unit]  
  2. Description=Subversion protocol daemon  
  3. After=syslog.target network.target  
  4.   
  5. [Service]  
  6. Type=forking  
  7. EnvironmentFile=/etc/sysconfig/svnserve  
  8. ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS  
  9.   
  10. [Install]  
  11. WantedBy=multi-user.target  

 

找到 svn 的 service 配置文件 /etc/sysconfig/svnserve 編輯配置文件
[plain]  view plain  copy
 
  1. vi /etc/sysconfig/svnserve  

將 OPTIONS="-r /var/svn" 改為 svn 版本庫存放的目錄,:wq 保存退出

在提示符下輸入

[plain]  view plain  copy
 
  1. systemctl enable svnserve.service  
啟動服務:
[html] view plain copy
  1. systemctl start svnserve.service  
查看服務列表狀態
[html] view plain copy
  1. systemctl list-units --type=service  

systemctl list-unit-files
 

重啟服務器,輸入

[plain]  view plain  copy
 
  1. ps -aux | grep 'svn'  


看 svn 服務啟動了沒有


免責聲明!

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



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