Track your local R scheduled tasks with CommandCenter2000!!!
来源:互联网 发布:北京赛车pk10数据采集 编辑:程序博客网 时间:2024/06/05 15:17
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:
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:
(Follow the steps in the schematic above: red for setup, and yellow to run it. These are explained below)
- 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" - 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)!
- OK, now tasks will be firing off! Now you need to get the command Center script from my github account. Go
it now!- This contains:
- the CommandCenter R script
- 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
- the html file that reports the status of each task.
- ignore the rest of the stuff
- Ok, now you have a local CommandCenter2000!!!.
- Set up the WORKING DIRECTORY to wherever you installed the folder.
- 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:
- Copy the block of code that looks like it should be copied. (hint, there’s START and END comments). Within each:
- Give that script a human name (this is what will be displayed)
- Specify the path and name of the R file (remember the whole “/” vs “” debacle for windows paths)
- Specify the path and name of the .bat file
- That’s it! Rinse and repeat for every script that you would like on your CommandCenter2000!!!
- Copy the block of code that looks like it should be copied. (hint, there’s START and END comments). Within each:
- This contains:
- 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.
- Everytime you click it, you’ll get the html file coming up shown above. In detail:
- “thing“: is just the name of the analysis
- “lastRun“: is how long ago the analysis ran (in days… although obviously this is configurable).
- “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: This mouseover effect will help you debug… using the following two options
- “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)
- “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.
- Track your local R scheduled tasks with CommandCenter2000!!!
- Restarting Web Services and Scheduled Tasks with a Batch File
- Uncaught exceptions in scheduled tasks
- task:scheduled-tasks cron表达式
- track your activties
- Reach for your Matlab data with R
- Java Spring @Scheduled tasks executing twice
- Spring任务调度 task:scheduled-tasks
- Spring任务调度<task:scheduled-tasks>(定时器)
- Spring Boot之定时调度Scheduled Tasks
- Spring任务调度<task:scheduled-tasks>
- local variable 'r' used with having been inibiavlzed(初始化)
- Supplementing your R package with a Shiny app
- Supplementing your R package with a Shiny app
- Queuing tasks with Redis
- reviewboard-使用RBtools工具提交review申请,提示more files in your changeset has history scheduled with commit.
- [C#] .NET调用Windows Scheduled Tasks 计划任
- Running PHP cron jobs – regular scheduled tasks in PHP
- Linux下TCP/IP网络编程——结课考试知识总结
- 自己总结的hql新增、删除、查询与sql的新增、删除、查询区别
- Android Studio 2.1.1 运行BUG
- 关于设备的唯一标识符
- Android获取屏幕高度、状态栏高度、标题栏高度
- Track your local R scheduled tasks with CommandCenter2000!!!
- spi 设置speed
- 《项脊轩志》
- oracle学习笔记 计算机缓存技术工作机制
- SOAP webserivce 和 RESTful webservice 对比及区别
- Apache Thrift
- webdriver获得文本
- Java中的equals和hashCode方法详解
- 安装vs_addin 支持2013