systemd所管理的服务通常位于:/lib/systemd/system/,如果细心的话会发现有些xxx.service中有带“@” at符号的。这种符号表示,这是一个支持“模板”(官方叫template,个人觉得称为“参数”更比较形象)的systemd 服务,@符号后面的内容会被当成变量传递到这个服务中,作为参数使用。
原文摘录如下:
OpenVPN is a templatized service under systemd. The services are named [email protected]. So you should be starting your /etc/openvpn/myvpn.conf instance with
systemctl start [email protected]
举个例子:
如下图所示,在看过之后都会好奇:
-
@符号是做什么用?
-
文件中%i这个变量是怎么来的有何用?
那么在了解了上文提到的知识后,就会明白@后面的内容实际上就是%i要替换的内容。
如果在配置OpenVPN客户端时,配置文件的名字叫做“ebt-aliyun-hangzhou-120.26.161.168.conf”,那么在启动这个服务的时候,如要这样启动:
1
|
sudo
systemctl start [email protected]
|
查看服务的运行状态也需要类似的语法:
1
|
sudo
systemctl status [email protected]
|
附:
排错和搜索类似问题的小技巧:最好使用“Google+英文”的搜索方式,如在Google搜索框内输入“ubuntu 16.04 openvpn client systemd”可能更快的找到问题的解决办法。
参考链接:
Correct way of systemd for OpenVPN client on 16.04 Server?
tag:ubuntu16.04,openvpn client,openvpn systemd
--end--