systemctl设置svn开机启动以及service文件的写法

来源:互联网 发布:js设置css样式display 编辑:程序博客网 时间:2024/06/05 10:04

使用systemd配置SVN服务器开机自动启动步骤比较简单。步骤如下:


1) 在/etc/systemd/system/目录创建单元文件,并且保证只能被root用户编辑:

vim /etc/systemd/system/svn.service

chmod 664 /etc/systemd/system/svn.service

其中,“svn.service”是我们自定义的服务单元文件名称,可以根据情况修改,下同。

2)打开svn.service文件,添加服务配置:


[Unit]
Description=Subversion Server
[Service]
Type=forking
ExecStart=/usr/bin/svnserve --daemon --root /software/svn
ExecStop=/usr/bin/killall svnserve
Restart=always
[Install]
WantedBy=default.target





其中,“/software/svn”是SVN仓库的根路径,请根据情况修改。

3)通知systemd有个新服务添加:

systemctl daemon-reload

4)启动和停止SVN服务

systemctl start svn.service

systemctl stop svn.service

用于测试刚才创建的服务单元是否工作正常。

5)配置开机自动启动

systemctl enable svn.service


其他有用的命令

1)列出systemd管理的所有服务状态

 systemctl --type service  --all

----------------------------------  Show all properties/all units currently in memory,
                                           including dead/empty ones. To list all units installed on
                                           the system, use the 'list-unit-files' command instead.

 systemctl --type service  --state active --all

---------------------------------- List units with particularLOADorSUBorACTIVEstate


systemctl list-unit-files

-----------------------------------------To show all installed unit files  

2)检查SVN服务运作状态 

systemctl status svn.service



原创粉丝点击