How to run an R script in crontab

前端 未结 3 1731
不知归路
不知归路 2021-01-15 06:44

Using crontab -e I\'ve tried:

* * * * *  Rscript /home/.../file.r
* * * * * /usr/lib/R/bin/Rscript /home/.../file.r
* * * * * /usr/bin/Rscript /home/.../file         


        
3条回答
  •  时光取名叫无心
    2021-01-15 07:31

    in my user level crontab I run a R script to collect tweets from various sources.

    I used: crontab -u myusername -e added this to the end of my crontab file

    0 0 * * * /home/bob/Documents/SWtweets/tweetbash.sh

    I ran it as a user vs root, don't what difference it makes, but it only worked for me when I ran it at user level.

    below is what I put in my tweetbash.sh shell script, which tells the bash program to run the R script located at the path indicated.

    #! /bin/bash R CMD BATCH /home/bob/Documents/SWtweets/tweets.R

    did chmod +x tweetbash.sh

    it works for my purposes.

    Bob

提交回复
热议问题