繁体   English   中英

Crontab 不执行 R 脚本

[英]Crontab doesn't execute R script

我正在尝试通过添加以下行在我的系统上设置 Cron 作业

17 12 * * * Rscript ~/path/to/file/script.R > ~/output_`date +\%d\%m\%y`.txt 2>&1

但是,我看不到正在写入输出的文件。 我查阅了以下答案,但无济于事:

为什么我的 crontab 没有触发

CronJob 未运行

当我在终端上运行以下命令时:

Rscript ~/path/to/file/script.R > ~/output_`date +\%d\%m\%y`.txt 2>&1

我按预期得到输出文件。 我还在 crontab 中添加了以下行:

* * * * * echo hi > ~/output.txt 2>&1

它工作得很好。 我不确定第一个命令有什么问题。 任何帮助,将不胜感激。 谢谢。

尝试以下技巧,创建一个脚本 script.sh,如下所示 -

cat script.sh
Rscript ~/path/to/file/script.R > ~/output_$(date +\%d\%m\%y).txt 2>&1

然后在 crontab 中创建以下条目。

17 12 * * * /bin/bash /path/to/script.sh

我解决了这个问题通过更换Rscript在我的crontab用/usr/local/bin/Rscript (或任何你RSCRIPT所在-做which Rscript找出)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM