如何将日期(或通常 shell 脚本的结果)传递给 supervisord 中的命令
How to pass date (or in general the result of a shell script) to command in supervisord
我有一个程序需要重复 运行。现在,我使用 supervisord 的 autorestart 来做到这一点。目前我有:
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 支持的不仅仅是 %(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
我有一个程序需要重复 运行。现在,我使用 supervisord 的 autorestart 来做到这一点。目前我有:
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 支持的不仅仅是 %(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