systemd配置文件语法
systemd配置文件采用INI格式,包含多个节(section),每个节包含多个键值对(key-value pair)。
- 节(section)
节是由方括号括起来的名称,如:
[Unit]
Description=My Service
- 键值对(key-value pair)
键值对由等号分隔,如:
ExecStart=/usr/bin/my-service
- 注释
注释以分号或井号开头,如:
# This is a comment
; This is also a comment
- 转义字符
如果键值对中需要使用等号或分号,可以使用反斜杠进行转义,如:
ExecStart=/usr/bin/my-service --config-file=/etc/my-service\=config.ini
- 继承
systemd配置文件支持节之间的继承关系,通过使用Include指令来实现。例如:
[Unit]
Description=My Service
[Service]
ExecStart=/usr/bin/my-service
[Install]
WantedBy=multi-user.target
; Include additional configuration
Include=/etc/systemd/my-service.conf
在上面的例子中,/etc/systemd/my-service.conf中的配置将被继承到当前配置文件中
原文地址: https://www.cveoy.top/t/topic/fdEj 著作权归作者所有。请勿转载和采集!