【发布时间】:2019-06-28 03:31:53
【问题描述】:
Systemd 支持别名。例如“httpd.service”
ls -l /etc/systemd/system/httpd.service
/etc/systemd/system/httpd.service -> /usr/lib/systemd/system/apache2.service
此文件的内容:
[Unit]
Description=The Apache Webserver
...
[Install]
WantedBy=multi-user.target
Alias=httpd.service apache.service
我想在脚本中解析别名。
例子:
如果输入是“httpd.service”,那么输出应该是“apache2.service”
我可以为这个脚本使用 shell 或 python。
如何以 systemd 方式做到这一点?
阅读符号链接可能会起作用,但我想有一种更正式的方法来解析别名。
【问题讨论】: