【问题标题】:Bash Redirection Not Working with RscriptBash 重定向不适用于 Rscript
【发布时间】:2021-09-25 21:48:09
【问题描述】:

我正在编写一系列需要将输出存储在集中式日志文件中的作业。我在 unix &> 中使用标准重定向命令将标准输出重定向到文件。

但此语句不会将日志重定向到 Rscript 命令的文件。它适用于所有其他 python、sas 和 jupyter 工作。

Rscript /notebooks/notebooks/Rsamplemode.R &> /out/store.log

没有东西被写入文件 /out/store.log 而是打印到标准输出

我已经做了 whoami 并且我目前是 root 用户。

【问题讨论】:

  • 我假设你不使用bash
  • 它是 kubernetes pod 中的一个外壳。我使用 echo $SHELL 检查它是哪个 shell,它返回空白。
  • 此命令通常从 kubernetes 规范中执行 命令:/bin/sh -c >
  • 如果是 sh,&> 将不起作用。
  • sh 不理解 &>(在 bash 和其他一些 shell 中,重定向标准输出和标准错误)

标签: bash rscript


【解决方案1】:

试试 tee:

Rscript /notebooks/notebooks/Rsamplemode.R 2>&1 | tee /out/store.log

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-28
    • 2012-08-20
    • 1970-01-01
    • 1970-01-01
    • 2010-12-08
    • 2012-03-27
    • 2013-10-31
    • 2014-12-02
    相关资源
    最近更新 更多