gpt4 book ai didi

linux - Crontab 不执行 R 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 12:30:51 26 4
gpt4 key购买 nike

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

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

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

Why did my crontab not trigger

CronJob not running

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

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

关于linux - Crontab 不执行 R 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43362914/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com