3

This systemd startup script refuses to run, but I just can't figure out why.

[Unit]
Description=IP Address on Boot Screen

[Service]
ExecStart=/usr/bin/ifconfig eth0 | awk '/inet / {print $2}' | cut -f2 -d: > /etc/issue

[Install]
WantedBy=multi-user.target

Obviously the problem is with the ExecStart but I just can't see any errors with it!

4

1 回答 1

7

您正在传递一个 shell 命令。在 systemd 启动时,没有设置 shell,也没有设置环境变量。因此,systemd 不知道如何处理awk,因为没有 $PATH。

ExecStart=选项设置为:

/bin/sh -c '/usr/bin/ifconfig eth0 | /bin/awk \'/inet / {print $2}\' | /bin/cut -f2 -d: > /etc/issue'
于 2013-10-25T06:09:59.793 回答