Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

systemd startup script fails to run

Tags:

systemd

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!

like image 326
crankshaft Avatar asked Nov 26 '25 02:11

crankshaft


1 Answers

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'
like image 94
Sergey Kanaev Avatar answered Nov 28 '25 17:11

Sergey Kanaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!