How to run an R script in crontab

前端 未结 3 1273
-上瘾入骨i
-上瘾入骨i 2021-01-15 07:02

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:38

    For what it is worth here is CRANberries entry which has worked (multiple times) every day for 5+ years:

    # every few hours, run cranberries
    11 */2 * * *    edd     ~/cranberries/cranberries.r
    

    Of note here are

    1. The time specification, here 11 mins past the hour every two hours
    2. The user
    3. The complete path, using 'globbing' to expand ~ to $HOME for edd

    and after that you just have to make sure the script is actually executable. Whether you use Rscript, littler or R BATCH CMD does not matter.

提交回复
热议问题