【问题标题】:How to pipe Systemd service standard output from ExecStart to shell, ex. bash?如何将 Systemd 服务标准输出从 ExecStart 传输到 shell,例如。重击?
【发布时间】:2023-03-14 09:40:01
【问题描述】:

我有一个 Systemd 服务,它启动我需要作为普通 Bash 脚本执行的输出过程

[Unit]
Description=Example app

[Service]
Type=simple
PIDFile=/var/run/app.pid
Sockets=app.socket
StandardInput=fd:app.socket
#StandardOutput=fd:sh
StandardError=journal
ExecStart=/usr/bin/app -a | sh # 

[Install]
WantedBy=default.target

应用程序的输出不是执行,而是进入日志。

告诉我如何解决这个问题?

【问题讨论】:

    标签: linux bash service sh systemd


    【解决方案1】:

    你不能真正在 ExecStart 中使用管道,但你可以这样做:

    ExecStart=/bin/bash -c '/usr/bin/app -a | sh '
    

    【讨论】:

      猜你喜欢
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多