Linux下设置svn开机自启动

方式一:centos 7 设置svn开机自启动 使用新的systemctl 服务命令  (笔者成功验证过,该方式可行)
  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  
启动服务:
  1. systemctl start svnserve.service  
查看服务列表状态
  1. systemctl list-units --type=service  

systemctl list-unit-files
 

重启服务器,输入

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


看 svn 服务启动了没有

原文地址:https://www.cnblogs.com/keta/p/8629450.html