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
-
是一个连词号,表示抑制错误
, 即发生错误的时候,不影响其他命令的执行;比如
EnvironmentFile=-/etc/profile
如果/etc/profile
不存在也不会抛出错误。这里有篇文章写的很不错,你可以参考。