【问题标题】:How to pass date (or in general the result of a shell script) to command in supervisord如何将日期(或通常是 shell 脚本的结果)传递给 supervisord 中的命令
【发布时间】:2015-11-06 00:41:06
【问题描述】:

我有一个需要重复运行的程序。现在,我使用 supervisord 的自动重启来做到这一点。目前我有:

command=myprogram --output-file=logfile.log

我想要类似的东西:

command=myprogram --output-file=logfile_%(date)s.log

将输出文件指定为logfile_2015_08_13.log, 除了supervisord只支持%(program_name)s%(process_num)02d等。

【问题讨论】:

    标签: supervisord


    【解决方案1】:

    Supervisord 支持的不仅仅是%(program_name)s, %(process_num)02d。你可以选择你的环境变量:Supervisord Environment

    但是我认为您不能在 supervisord 配置中传递 shell 命令。我会这样做:

    编写一个 shell 脚本并使用 date 命令调用您的程序。让我们把它保存为run.sh

    #!/bin/bash
    myprogram --output-file=logfile_`date +%Y-%m-%d`
    

    将你的 shell 脚本作为命令传递给 supervisord

    command=/path/to/run.sh
    

    【讨论】:

    • 谢谢。这可能是现在最简单(如果不是唯一)的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 2022-01-23
    • 2022-10-04
    • 1970-01-01
    相关资源
    最近更新 更多