task_scheduling: Task Scheduling

Description Usage Arguments Details

Description

Add/remove a cronjob to automate an R script to your personal crontab

Usage

1
2
3
4
5
6
7
addCronjob(name, desc = NULL, env_vars, scheduled_time, script_path,
  overwrite = FALSE, verbose = FALSE, warn = FALSE, bashrc = TRUE,
  logLevel = "info", textLevel = "none")

cronjobExists(name)

deleteCronjob(name)

Arguments

name

A unique name for this cronjob

desc

A description of what the script does

env_vars

A list of environment variables that need to be set for this cronjob

scheduled_time

A list or string describing when the task should be run.

script_path

The filepath to the script you want to automate

overwrite

If the cronjob already exists, should it be overwritten?

verbose

Should extra messages be displayed while the cronjob is being built?

warn

Should errors stop the function or just give an warning?

bashrc

Should the user's .bashrc file be loaded before running the script?

logLevel

What is the minimum message level that should be logged?

textLevel

What is the minimul message level that should be texted, if texting is enabled?

Details

cron does not start a shell and therefore doesn't load environment variables that would normally get loaded. Use env.var to set variables that are needed by your script and/or set bashrc = TRUE to load the user's .bashrc file each time before the script is run.

scheduled_time should be either a named list containing any combination of minute (0-59), hour (0-23), day_of_month(1-31), month(1-12)(Jan-Dec), day_of_week(0-7)(Sun-Sat) or a properly formatted cron string For example, scheduled_time = list(minute=30, hour=7, day_of_week=2) would result in the task being scheduled for 7:30AM every Tuesday. scheduled_time = "30 7 * * 2" would accomplish the same thing.

script_path should point to the location of a script you wish to automate. The script will be copied to the .crontabR directory in your home directory. Additional code will be copied to the beginning and end of the script so that crontabR's logging functions will work. It is this modified copy of the script that will be run by crontabR.

cronjobExists reads your personal crontab to see if a cronjob of the given name has been added by crontabR.

deleteCronjob will remove the lines in your crontab associated with the named cronjob. It will also delete the script from the .crontabR directory.


ebailey78/crontabR documentation built on June 5, 2019, 7:27 a.m.