【问题标题】:systemd startup script fails to runsystemd 启动脚本无法运行
【发布时间】:2014-03-05 06:15:02
【问题描述】:

这个 systemd 启动脚本拒绝运行,但我就是不知道为什么。

[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

显然问题出在ExecStart,但我看不到任何错误!

【问题讨论】:

    标签: systemd


    【解决方案1】:

    您正在传递一个 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'
    

    【讨论】:

      猜你喜欢
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 1970-01-01
      • 2018-10-04
      相关资源
      最近更新 更多