Visualising scheduled tasks on Windows with R
I do most of my work on Windows 10, with the usual terminal sessions via SSH to Linux or VirtualBox VM for Ubuntu. Quite often though I have need to have tasks run automatically on my machine while I’m testing them before integrating into larger production deployments. A great tool is the
taskscheduleR add-in for R Studio. It provides a very simple interface to the Windows’ 10 Task Scheduler (which is like
Schedule R scripts/processes with the Windows task scheduler. This allows R users to automate R processes on specific timepoints from R itself. The package is basically a wrapper around the Schtasks.exe functionality. More information about schtasks can be found at https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357 or at the doc folder inside this package.
You can find out much more about it at the GitHub page here https://github.com/bnosac/taskscheduleR
What is really useful though is by calling the library underpinning the R Studio add-in, and with a few lines of R code, it is possible to create a simple but easy to view chart of when various R scripts will be executed —
mutate(next_run_time = dmy_hms(next_run_time)) %>%
filter(author == “<<put the author name here>>) %>%
mutate(task_name = factor(task_name, levels = unique(task_name))) %>%
ggplot(aes(next_run_time, task_name)) +
What this does is
- use the
taskscheduler_lsfunction to list all of the scheduled tasks
- convert to a data frame
- clean up the names using
- cast the next run time to a date-time object
- filter by the author, in this case replace with your own value
- sort by next run time
- mutate the task name to use factors
- plot a scatter plot
This ends up looking like the below, although I’ve removed the script names for privacy reasons.
It just gives a very simple way to see when your script is going to run next.