Track your local R scheduled tasks with CommandCenter2000!!!

转载 2016年06月01日 15:22:15

There are many ways to automate your scripts running, for example using RScript, or in-R itself (and now even as an add-in for RStudio) (check all here). But after a while, it can get a bit overwhelming to track tasks and ensure they are firing as planned. In order to address this, I have developed some futuristic advanced tech that lets us do that. I hereby present to you: the CommandCenter2000!!! Yes, it’s Y2K compliant! This is what it looks like:

 

Capture

 

It has the following features:

  • It’ll tell you when the script ran last
  • whether it was successful or not (green/red light)
  • and will help you rerun failed scripts in 2 ways.

How to make your own:

diagram

(Follow the steps in the schematic above: red for setup, and yellow to run it. These are explained below)

    1. Setup the folders where there are running tasks. Concretely, inside the working folder for each script, you need a .bat file that will run that specific script. Within the bat file*, the code will look like this for example:

      @echo off
      "C:Program FilesRR-3.2.2binx64R.exe" --vanilla --slave CMD BATCH "D:Project Xanalyzer.R"

    2. OK, now you need to schedule the task in Windows (I like scheduling it myself so that I can set some specific requirements… in particular, I want tasks to fire only if connected to certain wifi). Don’t know how to do this?Check this out (that’s how I learned)!
    3. OK, now tasks will be firing off! Now you need to get the command Center script from my github account. Go


      it now!

      1. This contains:
        1. the CommandCenter R script
        2. a .bat file that will run the CommandCenter2000!!! itself. I recommend creating a shortcut to this bat file on your desktop or whatever. That way you can run it whenever
        3. the html file that reports the status of each task.
        4. ignore the rest of the stuff
      2. Ok, now you have a local CommandCenter2000!!!.
        1. Set up the WORKING DIRECTORY to wherever you installed the folder.
        2. Now, for each script you’d like to track in the CommandCenter2000!!!, add a reference to that script in the main CommandCenter2000!!! script. By “reference”, I mean:
          1. Copy the block of code that looks like it should be copied. (hint, there’s START and END comments). Within each:
            1. Give that script a human name (this is what will be displayed)
            2. Specify the path and name of the R file (remember the whole “/” vs “” debacle for windows paths)
            3. Specify the path and name of  the .bat file
          2. That’s it! Rinse and repeat for every script that you would like on your CommandCenter2000!!!
    4. OK, setup is done. Now, whenever you want to check the status of scripts, you can just run your command center. Of course, you could run the CommandCenter2000!!! itself on a schedule… but putting something on a schedule to check whether other things are running on schedule correctly is a bit…… mind-bending. Careful you don’t break reality.
    5. Everytime you click it, you’ll get the html file coming up shown above. In detail:
      1. thing“: is just the name of the analysis
      2. lastRun“: is how long ago the analysis ran (in days… although obviously this is configurable).
      3. status“: (this is the last column) has a red or green light to indicate whether the script ran successfully or not. If it didn’t, the red light will have  a mouseover effect whereby you’ll be able to tell what the error was…. which looks like this: ddThis mouseover effect will help you debug… using the following two options
      4. SomethingWrong“: provides a link to the R file,in case the script failed because your R script is messed up. Don’t click the link, but right click and “copy link”, then open it from R (sorry for roundabout way, but unfortunately it’s very difficult to launch a local file from HTML for security)
      5. runLink: provides a link to the bat file that will run the script (more on this later). Use this if  the script failed but you think the R script is correct and just needs to rerun (for example if the network crapped out), just click, download the bat file and run it… everything will rerun automatically.

 

So clearly, this is a very rough first-pass attempt to keep track of scheduled tasks. If you’d like to collaborate, I’d love to evaluate some pull-requests.

 

 

*WARNING: This approach uses .bat files, which could damage your computer or corrupt your data. Be VERY CAREFUL, and don’t trust anybody else’s bat files without first examining them in a text editor.

如何安装、使用IntelliJ IDEA?

If you have successfully installed Intellij IDEA on your computer, it's time to run it for the fir...
  • major1985
  • major1985
  • 2016年01月04日 23:29
  • 1485

Git常用命令实践总结

Git常用命令
  • Quincuntial
  • Quincuntial
  • 2016年10月21日 18:48
  • 2785

解决使用android studio中的git update后报错当前未提交的代码被覆盖

由于项目里的小伙伴把结构目录改了,然后我在update之前没有把本地代码上传到本地git仓库内,导致出现了如下警告Local changes were not restored Before upda...
  • lj402159806
  • lj402159806
  • 2016年12月29日 11:06
  • 1251

使用Spring的@Scheduled实现定时任务

Spring配置文件xmlns加入 xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation中加入 ...
  • PrisonBreak_
  • PrisonBreak_
  • 2015年10月16日 16:23
  • 90439

spring Scheduled cron定时调度时间的设置

CronTrigger配置格式: 格式: [秒] [分] [小时] [日] [月] [周] [年]序号 说明 是否必填 允许填写的值 允许的通配符 1 ...
  • a714115852
  • a714115852
  • 2015年11月13日 10:48
  • 1729

spring @Scheduled注解 定时任务

spring3.2 @Scheduled注解 定时任务 1.首先加入下载spring3.2 ,http://projects.spring.io/spring-framework/   2.加入...
  • zhihui1017
  • zhihui1017
  • 2016年01月12日 15:23
  • 680

Spring @Scheduled 执行两次 问题总结

参考:http://bbs.csdn.net/topics/391054322 使用 Spring @Scheduled 注解实现定时任务:  1:servlet.xml中添加了 task命名空间...
  • u010802573
  • u010802573
  • 2015年12月30日 19:14
  • 6195

Spring Scheduled定时任务动态修改cron参数

使用spring @scheduled注解可以方便的设定定时任务,但是对于定时参数需要变化的情况就会很不方便,如果要实现更改定时参数,就要停止服务,更改参数,重新部署。 对于这种需求, 可以利用Ta...
  • zhao1949
  • zhao1949
  • 2017年02月04日 15:50
  • 5836

Spring 定时任务之 @Scheduled cron表达式

一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素。 按顺序依次为 秒(0~59) 分钟(0~59) 小时(0~23) 天(月)(0~31,但是你需要考虑...
  • silyvin
  • silyvin
  • 2016年07月08日 11:34
  • 5793

定时任务调度之Sping的@Scheduled注解实例详解

Sping的@Scheduled注解实现容器启动后执行、定时任务调度作业。 详解更多精彩请阅读 东陆之滇的csdn博客:http://blog.csdn.net/zixiao217...
  • zixiao217
  • zixiao217
  • 2016年10月25日 20:13
  • 1287
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Track your local R scheduled tasks with CommandCenter2000!!!
举报原因:
原因补充:

(最多只允许输入30个字)