本文介绍了Raspbian/Linux如何将我的R脚本作为crontabs运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题,但是我是新来的:我正在尝试在Raspberry Pi上安排一些Rscript,但一直失败.首先它什么也没做,现在却说它无法运行我的crontab,因为它们的命令很糟糕.

This is probably a very basic question but I'm new to this:I'm trying to schedule some Rscript on my Raspberry Pi but keep failing with it. First it didn't do anything and now it says that it can't run my crontabs because they have 'bad commands'.

我尝试了两种不同的样式:

I have tried in two different styles:

sudo crontab -e

17**** cd [/home/pi/R/projects] && Rscript scraper_srf.R
20**** cd [/home/pi/R/projects] && Rscript scraper_srf.R
29**** cd [/home/pi/R/projects] && Rscript 20min_retry_update_08_06_2020.R
30 21*** cd [/home/pi/R/projects] && Rscript soweitsieht_update_10_06_2020.R

sudo crontab -e

32**** Rscript /home/pi/R/projects/scraper_srf.R
20**** Rscript /home/pi/R/projects/scraper_blick.R
29**** Rscript /home/pi/R/projects/20min_retry_update_08_06_2020.R
3021*** Rscript /home/pi/R/projects/soweitsieht_update_10_06_2020.R

thx为您提供帮助

推荐答案

以下方法对我有用:

1)连同R文件一起制作一个shell脚本(myScript.sh)

1) make a shell script (myScript.sh) along with your R files

#!/bin/sh
cd /myScriptDir
Rscript myScript.R

2)测试shell脚本

2) test the shell script

cd /myScriptDir
sh myScript.sh

3)编辑crontab:

3) edit crontab :

# m h  dom mon dow   command
0 8 * * * sh /myScriptDir/myScript.sh

如@amatsuo_net所述,*之间必须有空格

as mentionned by @amatsuo_net, space between * is necessary

这篇关于Raspbian/Linux如何将我的R脚本作为crontabs运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:52