Jos*_*ink 5 bash shell redirect
我想通过日志记录程序重定向 bash 脚本的输出。具体来说,Apache 的 logrotate 实用程序。重定向需要在脚本本身内设置。
如果在命令行上完成重定向,则在执行脚本时,它将如下所示:
myscript | logrotate -l $LOGFILE.%F 86400 2>&1
Run Code Online (Sandbox Code Playgroud)
以下是脚本内部用于完成输出重定向的一些伪代码,但它不起作用:
exec >(logrotate -l $LOGFILE.log.%F 86400) 2>&1
Run Code Online (Sandbox Code Playgroud)
我不认为脚本可以重定向它自己的输出。您可以为其编写一个包装脚本吗?
我的脚本:
myscript.real "$@" | logrotate -l $LOGFILE.%F 86400 2>&1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1258 次 |
| 最近记录: |