=-和=有什么区别?=-是什么含义?

EnvironmentFile=-/etc/profile

EnvironmentFile=/etc/profile

有什么区别?

[Unit]
Description=Run command at shutdown
Before=shutdown.target reboot.target

[Service]
EnvironmentFile=-/etc/profile
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/bash /home/test/test.sh

[Install]
WantedBy=multi-user.target

阅读 2.1k
1 个回答

-是一个连词号,表示抑制错误, 即发生错误的时候,不影响其他命令的执行;
比如EnvironmentFile=-/etc/profile如果/etc/profile不存在也不会抛出错误。

这里有篇文章写的很不错,你可以参考。