您的位置:首页 > 运维架构 > Linux

Scheduling R scripts and processes on Windows and Unix/Linux

2017-03-08 10:18 483 查看
2 new R packages were put on CRAN last week by BNOSAC (www.bnosac.be).

One package for scheduling R scripts and processes on Windows (taskscheduleR) and
Another package for scheduling R scripts and processes on Unix / Linux (cronR)
These 2 packages allow you to schedule R processes from R directly. This is done by passing commands directly to cron which
is a basic Linux/Unix job scheduling utility or by using the Windows Task Scheduler. The packages were developed for beginning R users who are unaware of that fact that R scripts can also be run non-interactively and can be automated.

We blogged already about the taskscheduleR R package at this
blog post and alsohere.
This time we devote some more details to the cronR R package.

The cronR package allows to

Get the list of scheduled jobs
Remove scheduled jobs
Add a job
a job is basically a script with R code which is run through Rscript
You can schedule tasks ‘ONCE’, ‘EVERY MINUTE’, ‘EVERY HOUR’, ‘EVERY DAY’, ‘EVERY WEEK’, ‘EVERY MONTH’ or any complex schedule
The task log contains the stdout & stderr of the Rscript which was run on that timepoint. This log can be found at the same folder as the R script

The package is especially suited for persons working on an RStudio server in the cloud or within the premises of their corporate environment. It allows to easily schedule processes. To make that extremely easy for beginning R users, anRStudio addin was
developed, which is shown in the example below. The RStudio addin basically allows you to select an R script and schedule it at specific timepoints. It does this by copying the script to your launch/log folder and setting up a cronjob for that script.

The example below shows how to set up a cron job using the RStudio addin so that the scripts are launched every minute or every day at a specific hour. The R code is launched through Rscript and the log will contain the errors and the warnings in case your
script failed so that you can review where the code failed.

Mark that you can also pass on arguments to the R script so that you can launch the same script for productXYZ and productABC.



Of course scheduling scripts can also be done from R directly. Some examples are shown below. More information at https://github.com/bnosac/cronR

We hope this will gain you some precious time and if you need more help on automating R processes, feel free to get
into contact. We have a special training devoted to managing R processes which can be given in your organisation. More information at our
training curriculum.



 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: