Raspbian/Linux 如何将 R 脚本作为 crontab 运行?

编程入门 行业动态 更新时间:2024-10-23 07:37:18
本文介绍了Raspbian/Linux 如何将 R 脚本作为 crontab 运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题,但我是新手:我正在尝试在我的 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

感谢您的帮助

推荐答案

以下方法对我有用:

1) 制作一个 shell 脚本 (myScript.sh) 和你的 R 文件

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 脚本作为 crontab 运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-27 04:43:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/679059.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   脚本   Raspbian   Linux   crontab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!