3
votes

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!

1

1 Answers

7
votes

You are passing a shell command. At the time systemd starts there is no shell and no environment variables set. Thus, systemd does not know how to handle awk, because there is no $PATH.

Set ExecStart= option to something like:

/bin/sh -c '/usr/bin/ifconfig eth0 | /bin/awk \'/inet / {print $2}\' | /bin/cut -f2 -d: > /etc/issue'