{"id":13736459,"url":"https://github.com/bnosac/cronR","last_synced_at":"2025-05-08T12:32:53.571Z","repository":{"id":9469310,"uuid":"58122946","full_name":"bnosac/cronR","owner":"bnosac","description":"A simple R package for managing your cron jobs.","archived":false,"fork":true,"pushed_at":"2023-12-12T08:26:18.000Z","size":220,"stargazers_count":288,"open_issues_count":7,"forks_count":38,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-24T16:17:23.288Z","etag":null,"topics":["cron","r","rstudio","scheduler"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kevinushey/cronR","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnosac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T10:22:10.000Z","updated_at":"2024-09-03T10:40:15.000Z","dependencies_parsed_at":"2023-01-16T20:16:43.555Z","dependency_job_id":null,"html_url":"https://github.com/bnosac/cronR","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnosac%2FcronR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnosac%2FcronR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnosac%2FcronR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnosac%2FcronR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnosac","download_url":"https://codeload.github.com/bnosac/cronR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224732129,"owners_count":17360416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","r","rstudio","scheduler"],"created_at":"2024-08-03T03:01:22.167Z","updated_at":"2024-11-15T04:31:51.224Z","avatar_url":"https://github.com/bnosac.png","language":"R","funding_links":[],"categories":["Backend","R"],"sub_categories":["Job Scheduling"],"readme":"cronR\n=========\n\n![cronR](tools/cronR-logo.png) \n\nSchedule R scripts/processes with the cron scheduler. This allows R users working on Unix/Linux to automate R processes at specific timepoints from R itself.\nNote that if you are looking for a Windows scheduler, you might be interested in the R package taskscheduleR available at\nhttps://github.com/bnosac/taskscheduleR\n\n\nBasic usage\n-----------\n\nThis R package allows you to \n\n* Get the list of scheduled jobs\n* Remove scheduled jobs\n* Add a job\n  + A job is basically a script with R code which is run through Rscript\n  + You can schedule tasks 'ONCE', 'EVERY MINUTE', 'EVERY HOUR', 'EVERY DAY', 'EVERY WEEK', 'EVERY MONTH' or any complex schedule\n  + The task log contains the stdout \u0026 stderr of the Rscript which was run on that timepoint. This log can be found at the same folder as the R script\n\nRStudio add-in\n-----------\n\nThe package also contains an RStudio addin. If you install the package and use RStudio version 0.99.893 or later you can just click to schedule a task. Just click Addins \u003e Schedule R scripts on Linux/Unix.\n\n![](tools/cronR-rstudioaddin.png) \n\n- Alternatively, run `cronR::cron_rstudioaddin()` to open the addin interface. If you use that addin to schedule scripts, by default it will copy the R scripts to your current working directory and launch the copied scripts from there. A different directory can be specified by passing an argument to the `RscriptRepository` parameter `cronR::cron_rstudioaddin(RscriptRepository = \"/path/to/your/deployment/directory\")`\n- You can also set the `CRON_LIVE` environment variable to specify a default directory to copy scheduled scripts to. This can be done by putting something like `CRON_LIVE=\"/path/to/your/deployment/directory\"` in your .Renviron or .Rprofile file. See ?Startup\n\n\nUsage\n-----------\n\nSome example use cases are shown below, indicating to schedule a script at specific timepoints.\n\n```\nlibrary(cronR)\nf   \u003c- system.file(package = \"cronR\", \"extdata\", \"helloworld.R\")\ncmd \u003c- cron_rscript(f)\ncmd\n\ncron_add(command = cmd, frequency = 'minutely', id = 'test1', description = 'My process 1', tags = c('lab', 'xyz'))\ncron_add(command = cmd, frequency = 'daily', at='7AM', id = 'test2')\ncron_njobs()\n\ncron_ls()\ncron_clear(ask = TRUE)\ncron_ls()\n\ncmd \u003c- cron_rscript(f, rscript_args = c(\"productx\", \"arg2\", \"123\"))\ncmd\ncron_add(cmd, frequency = 'minutely', id = 'job1', description = 'Customers')\ncron_add(cmd, frequency = 'hourly', id = 'job2', description = 'Weather')\ncron_add(cmd, frequency = 'hourly', id = 'job3', days_of_week = c(1, 2))\ncron_add(cmd, frequency = 'hourly', id = 'job4', at = '00:20', days_of_week = c(1, 2))\ncron_add(cmd, frequency = 'daily', id = 'job5', at = '14:20')\ncron_add(cmd, frequency = 'daily', id = 'job6', at = '14:20', days_of_week = c(0, 3, 5))\ncron_add(cmd, frequency = 'daily', id = 'job7', at = '23:59', days_of_month = c(1, 30))\ncron_add(cmd, frequency = 'monthly', id = 'job8', at = '10:30', days_of_month = 'first', days_of_week = '*')\ncron_add(cmd, frequency = '@reboot', id = 'job9', description = 'Good morning')\ncron_add(cmd, frequency = '*/15 * * * *', id = 'job10', description = 'Every 15 min')   \ncron_ls()\ncron_clear(ask = TRUE)\n```\n\nBy default, when you use the functions `cron_add`, `cron_rm`, `cron_clear`, `cron_load`, a prompt will ask for your permission to update the cron schedule, unless you put the argument `ask=FALSE` in each of these functions, in which case you automatically allow to update the schedule. (new since R package version 0.6.0)\n\n\nInstall\n-----------\n\nMake sure the cron daemon (https://en.wikipedia.org/wiki/Cron) is running. On Debian this is done as follows.\n```\nsudo apt-get update\nsudo apt-get install -y cron\nsudo cron start\n```\n\n- For regular users, install the package from your local CRAN mirror with `install.packages(\"cronR\")`, for installing the development version of this package: `remotes::install_github(\"bnosac/cronR\")`\n- If you want the RStudio add-in to work, also install miniUI, shiny and shinyFiles\n\n```\ninstall.packages(\"cronR\")\ninstall.packages('miniUI')\ninstall.packages('shiny')\ninstall.packages('shinyFiles')\n```\n\nNow have a look at `?cron_add` or start the RStudio addin\n\nNotes\n-----------\n\n- Consider adding `options(echo = TRUE)` at the start of your R scripts in order to debug your scripts in case of errors.\n- Consider using argument `env` when calling `cron_add` if you need specific environment variables to be used in your script, These will be prepended to your script. E.g. as follows where you replace dry_run to FALSE to add it to your cron job list.\n\n```\ncmd \u003c- cron_rscript(\"/path/to/your/script.R\")\ncron_add(cmd, frequency = 'minutely', id = 'job1', description = 'Customers', \n         env = c(LANG = \"en_US.UTF-8\", R_LIBS_USER = Sys.getenv(\"R_LIBS_USER\"), YOUR_PROJECT_XYZ = getwd()), \n         ask = FALSE, dry_run = TRUE)\n```\n\n- Currently, `cronR` does not preserve or handle cron jobs not\ngenerated through the package. This will be handled some time in\nthe future. To be safe, you should run `cron_save(\"cron.backup\")`\nbefore fiddling around.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnosac%2FcronR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnosac%2FcronR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnosac%2FcronR/lists"}