How to run an R script in crontab

前端 未结 3 1707
不知归路
不知归路 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:28

    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.

提交回复
热议问题