Git Product home page Git Product logo

cronr's People

Contributors

adamcagle avatar atusy avatar cboettig avatar gerhardqux avatar jwijffels avatar kevinushey avatar llrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cronr's Issues

Using cronR with EIKON API (thomson reuters)

Hi,
I would like to use this package to schedule my script. However when I run my script through the scedule app I get an error. When I just run in the RStudio it works.

The problem seems to be the function "set_app_id" in this package https://github.com/ahmedmohamedali/eikonapir

Here is my code and log.output:

library(eikonapir)
set_app_id('F3AEA95748854609FA504275')

Log output
Error in new("RequestInfo", application_id = appId, port = 36036L, url = request_url, :
could not find function "new"
Calls: set_app_id -> RequestInfo
Execution halted

Do you have any idea why this is working in RStudio, but not when I run it using cronR?

unexpected path behavior under linux

For some reason, my repository path isn't getting preserved when cron is run from a crontab set by this very useful package.

Eg, given a toy test script file:

###test_script.R
cat(getwd())
###

The Rscript repository path: launch & log location dialog box looks correctly populated, eg it shows: /home/me/my_script_folder, where test_script.R lives

if I test it with run once test, eg:

nohup /usr/lib/R/bin/Rscript '/home/me/my_script_folder/test_script.R' >> '/home/me/my_script_folder/test_script.log' 2>&1 &

I see
/home/me/my_script_folder
in the log file, as expected.

however, if I set a CRON job for test_script.R say, every minute

eg:

$crontab -e
0-59 * * * * /usr/lib/R/bin/Rscript '/home/me/my_script_folder/test_script.R

the cat'd path is just /home/me in the log file, dropping the project folder /my_script_folder

I'm running CronR 0.4.0
Under Rstudio 1.2.1335
With R 3.6.0
on Ubuntu 18.04
bash is default shell

Problem programming a function monthly

Hi, I've trying to programm a function montly. I want that my function to run the first day every month at 2:00. Then, I've used this command:

library(cronR,)
    cmd<- cron_rscript("Informe_Mensual_Visits_Orders/Automatizar_Informes_Mensuales.R")
    cron_add(cmd, frequency = 'monthly', 
             id = 'informe_mensual,
             days_of_month = "first",
             at = '02:00',
             description = 'Informe_mensual_Visits_Orders')

But, when I used cron_ls(), R returs this:

## cronR job
## id:   informe_mensual
## tags: 
## desc: Informe_mensual_Visits_Orders
0 2 1 * 1 /usr/lib/R/bin/Rscript 'Informe_Mensual_Visits_Orders/Automatizar_Informes_Mensuales.R'  >> 'Informe_Mensual_Visits_Orders/Automatizar_Informes_Mensuales.log' 2>&1

Then, my function runs every monday. Does CronR define days_of_week =1 automatically?Is there any solution to solve this problem?
Thank you!

cronjobs parse into an extra "desc: tags:"-line when no environment is passed

With the introduction of environment options in v0.6.1, parsing seems to be broken. When no environment is passed, an additional empty line is inserted.

> cron_add("w","monthly",days_of_month="15th",ask=FALSE)
Adding cronjob:
---------------

## cronR job
## id:   ca9aaf633981f89df215b31c8e3621bb
## tags: 
## desc: 

0 0 15 * 1 w
> cron_ls()
## cronR job
## id:   ca9aaf633981f89df215b31c8e3621bb
## tags: 
## desc: tags:
## desc: 

0 0 15 * 1 w

This is caused by the if-statement at https://github.com/bnosac/cronR/blob/master/R/cron_add.R#L203 which evaluates to NULL when no environment is given. The NULL is still pasted and separated with an \n character. Hence, the empty line.

Task status

This is not a bug.
I would like to ask if there is any way to know the completion of R script.is it possible?
Thank you!

Clear jobs by id

Hi,

cron_clear function removes all jobs added by a user, is there a way to clear only specified jobs ?
Thanks

Operation not permitted

please help check, it seems like the administrator access for Rstudio is not permitted, but what else can I do?
macOS Monterey Version 12.3.1
13-inch, M1, 2020
RStudio
2022.02.0 Build 443
the log said: Fatal error: cannot open file '/Users/../myR.R': Operation not permitted
image
image
image

Can't complete Cron Job when python code is embed (through reticulate) inside the R script

I've created an R script that first launches a python script through the py_run_file() function and then executes some R code. I need to schedule the launch of such script at a certain hour of the day, and hence I used the package cronR. Unfortunately, when I call the script function just as a cron job, the job freezes and doesn't end. Here's a reproducible example:

library(reticulate)

today <- Sys.Date()

print(today)

use_python("/Users/nicocriscuolo/miniconda3/bin/python3.8",
           required = TRUE)

print("The function 'use_python()' works!")

py_run_file("/Users/nicocriscuolo/Desktop/test.py")

print(paste("Cron job ended on the ",
            today))

This is the content of the test.py file:

print("python script!")

Do you have any suggestion? Thanks a lot for your help!

ASIS Formatting

I'm trying to run cron jobs every 2 hours using the format 0 */2 * * * when I run, it is exceeding my API rate limit. I don't see any formatting guidelines in the readme so I'm wondering if this is a mistake I made or an issue with cronR. I'd use every hour but I'll need to run several jobs on a 20 minute interval to avoid exceeding a rate limit.

Allow user to specify working directory for RScript?

the behaviour of RScript can depend on a working directory (e.g. for a .Renviron that may contain credentials needed, etc). Of course we can construct our commands from scratch and add them with cron_add(), but it would be great if cron_rscript() could support an argument of workdir that would add a cd workdir before evaluating Rscript. If this sounds reasonable to you I'd be happy to prepare a PR.

cron job only runs once mode

Hi,

Thanks for this nice package nice package. I've also setup a VM using Mark's googleComputeEngineR package and then installed cronR.

When I try to schedule cron jobs through the add-on it only runs scripts that I set to run on 'ONCE' mode. Any idea of a direction I could take to find out the cause?

As an example i've set up a hello_world.R script to print a couple of sentences. the hello_world.log file is not populated so I assume it doesn't run at all.

This is the test cronjob I've set:
0-59 * * * * /usr/local/lib/R/bin/Rscript '/home/quba.tech/hello_world.R' >> '/home/quba.tech/hello_world.log' 2>&1

Application of cronR in Shiny App scheduled task

Hi,

I know about you via https://github.com/bnosac/cronR.

I am currently conducting research on real-time trading. I have 2 questions about real-time trading on shiny app.

  1. Start calculate the forecast price everyday 00:00AM.
  2. Matching a real-time bid/ask price to close a transaction.

source questions : https://community.rstudio.com/t/application-of-cronr-in-shiny-app-scheduled-task/9292/5

I do appreciate if you are willing shade me a light.
Thank you.

Best Regards
Ryo, Eng Lian Hu

Issue with run script by Cron on GCP Debian

I have few scripts which I try to run by CronR from Google Compute Engine and RStudio Server.
From Rstudio all scripts are works well. But then I try to run Cron it cause error

Error in curl::curl_fetch_memory(url, handle = handle) :
Operation was aborted by an application callback
Calls: dbWriteTable ... request_fetch -> request_fetch.write_memory ->
Execution halted

Could you please help to fix it

test fail

Please see the problems shown on
<https://cran.r-project.org/web/checks/check_results_cronR.html>.

Please correct before 2021-09-08 to safely retain your package on CRAN.

From the log in Additional Issues. Looks like Mac M1 has /opt folder where a user has access rights on or the /opt folder does not exist there.

* using log directory ‘/Users/ripley/R/packages/tests-devel/cronR.Rcheck’
* using R Under development (unstable) (2021-08-19 r80799)
* using platform: aarch64-apple-darwin20.6.0 (64-bit)
* using session charset: UTF-8
* using option ‘--no-stop-on-test-error’
* checking for file ‘cronR/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘cronR’ version ‘0.5.0’
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘cronR’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking use of S3 registration ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... OK
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(cronR)
  > test_check("cronR")
  ══ Skipped tests ═══════════════════════════════════════════════════════════════
  • On CRAN (2)
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Failure (test-verify_script_path.R:3:3): verify_rscript_path shows warning messages correctly ──
  `cronR:::verify_rscript_path("/opt")` did not produce any warnings.
  
  [ FAIL 1 | WARN 0 | SKIP 2 | PASS 1 ]
  Error: Test failures
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking re-building of vignette outputs ... OK
* checking PDF version of manual ... OK
* checking for detritus in the temp directory ... OK
* DONE

Status: 1 ERROR
See
  ‘/Users/ripley/R/packages/tests-devel/cronR.Rcheck/00check.log’
for details.

Can't see folder structure in the Addin within RStudio.

Firstly, thanks to a nice package. I was looking for a cron job utility on Google Cloud as the regular cron wasn't working as expect. I setup a VM using Mark's googleComputeEngineR package and then installed cronR.

The Addin seems to work but I can't see folder, for some reason the system may be blocking due to permissions or something? Have you seen this before ?

image

I tried to change folder permissions to 777 and also tried to set different working directory, but no luck.

flock support

Would there be a way to make sure that the previous process is finished before a new is launched?
I have seen that this should be done with flock.
So something like:

* * * * * flock -n tmp/my.lockfile  sh -c 'command'  >> logpath 2>&1

cronR replaces days_of_week="*" with "0,1,2,3,4,5,6" causes monthly cron to run daily on linux

Thank you for this package, I am finding it very useful and am trying to use cronR more generally rather than linux-level cron commands.

I have hit a behaviour where cronR replaces days_of_week="*" with "0,1,2,3,4,5,6" causes monthly cron to run daily on linux. This possible value for days_of_week is mentioned in the cronR vignette so I hope it is valid but the output is not given so I am not totally sure if this is an issue or expected (undocumented?) behaviour.

I have checked and I think the 2 values (resulting vs expected) have different behaviours at least for Linux and maybe generally on Unix-like systems.

Resulting: 
0 5 15 * 0,1,2,3,4,5,6 <cmd>
Expected: 
0 5 15 * * <cmd>

As a workaround I am using frequency = '0 5 15 * *' without days_of_week or days_of_month options set.

Thanks in advance!
Arlene

Supporting info:

--- Code ---- 

library("cronR")

cmd <- cronR::cron_rscript("./scripts/r/EHC001_run_report.R") 
cmd <- paste(paste("cd '", getwd(), "' && ", cmd, sep="")) 



# Add cron to crontab 
cronR::cron_add(command=cmd, frequency = "monthly", at="05:00", days_of_month = "15", 
                days_of_week = "*", id="EHC001", 
				        tags = c("monthly", "EHC001 - Communicating Devices"), 
				        description = "Communication status from estate health check data: Execute at 0500 UTC on the 15th of the month") 

--- Resulting output 

> cronR::cron_add(command=cmd, frequency = "monthly", at="05:00", days_of_month = "15", 
+                 days_of_week = "*", id="EHC001", 
+                 tags = c("monthly", "EHC001 - Communicating Devices"), 
+                 description = "Communication status from estate health check data: Execute at 0500 UTC on the 15th of the month") 
Adding cronjob:
---------------

## cronR job
## id:   EHC001
## tags: monthly, EHC001 - Communicating Devices
## desc: Communication status from estate health check data: Execute at 0500 UTC on
##   the 15th of the month
0 5 15 * 0,1,2,3,4,5,6 cd '/home/arlene.brown/projects/EHC001 - Communicating Devices' && /opt/R/4.0.2/lib/R/bin/Rscript './scripts/r/EHC001_run_report.R'  >> './scripts/r/EHC001_run_report.log' 2>&1

--- Linux-level console output for information
rlene.brown@aw17laldvrss001:~/projects/EHC001 - Communicating Devices$ uname -a 
Linux aw17laldvrss001 5.4.0-1037-aws #39~18.04.1-Ubuntu SMP Fri Jan 15 02:48:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
arlene.brown@aw17laldvrss001:~/projects/EHC001 - Communicating Devices$ crontab -l 

## cronR job
## id:   EHC001
## tags: monthly, EHC001 - Communicating Devices
## desc: Communication status from estate health check data: Execute at 0500 UTC on
##   the 15th of the month
0 5 15 * 0,1,2,3,4,5,6 cd '/home/arlene.brown/projects/EHC001 - Communicating Devices' && /opt/R/4.0.2/lib/R/bin/Rscript './scripts/r/EHC001_run_report.R'  >> './scripts/r/EHC001_run_report.log' 2>&1


--- Similar example from cronR vignette: 
cron_add(cmd, frequency = 'monthly', id = 'job8', at = '10:30', 
  days_of_month = 'first', days_of_week = '*')

--- I have referred to this web page as part of troubleshooting to confirm my understanding of Linux cron behaviour for the resulting / expected strings:
https://crontab.guru/#0_5_15_*_0,1,2,3,4,5,6
https://crontab.guru/#0_5_15__

Dataframe produced through cronR has wrong format.

I've created a script that reads data from two GitHub repositories, reformats the datasets, binds them together by rows and then writes everything in a new .csv file. Then, I scheduled the run of this script every hour through the functionalities of the cronR package.

Here's my code:

devtools::install_github("tidyverse/googlesheets4")

library(dplyr)
library(googlesheets4)
library(RCurl)

setwd(dir = "YOUR_WORKING_DIRECTORY")

###############################################################################
#================== TIME SERIES DATA FOR CASES AND DEATHS ====================#
###############################################################################

# 1. #####==== DATASETS =====#####

# 1.1 ###= Cases #####

# These files are updated on GitHub every day.
cases <- read.csv(text = getURL(url = "https://raw.githubusercontent.com/openZH/covid_19/master/COVID19_Cases_Cantons_CH_total.csv"),
                  header = TRUE,
                  stringsAsFactors = FALSE,
                  na.strings = c("", "NA"),
                  encoding = "UTF-8")

# Removed data for whole Switzerland and Leichtenstein
cases <- subset(x = cases,
                !is.element(el = canton,
                            set = c("CH", "FL")),
                select = c("date",
                           "canton",
                           "tested_pos"))

names(cases)[1] <- "Date"

# Dataset restructured according to the cases dataset format
cases <- reshape(data = cases,
                 idvar = "Date",
                 timevar = "canton",
                 v.names = "tested_pos",
                 direction = "wide",
                 )

names(cases) <- gsub(pattern = "tested_pos.",
                     replacement = "",
                     x = names(cases))

cases[is.na(cases)] <- 0

cases <- cases[order(cases$Date,
                     decreasing = FALSE), ]

# More updated dataset
cases2 <- read.csv(text = getURL(url = "https://raw.githubusercontent.com/daenuprobst/covid19-cases-switzerland/master/covid19_cases_switzerland.csv"),
                   header = TRUE,
                   stringsAsFactors = FALSE,
                   na.strings = c("", "NA"),
                   encoding = "UTF-8")

# Remove total daily cases for Switzerland
cases2 <- subset(x = cases2,
                 select = -c(CH))

# rbind between two cases datasets
cases_tot <- bind_rows(cases[1:7, ],
                       cases2)

rownames(cases_tot) <- seq(from = 1,
                           to = nrow(cases_tot),
                           by = 1)

write.csv(x = cases_tot,
          file = paste0(getwd(),
                        "/cases_tot.csv"),
          row.names = FALSE,
          quote = FALSE)

When I manually run my script everything is ok and the .csv produced is fine, but if you try to schedule the run of this script through the cronR package (from RStudio IDE click on Addins -> Schedule R scripts on Linux/Unix) the .csv saved is different just for the column "Date". In fact, the dates of the first dataset are on the first column, but the dates of the second dataset (to bind to the first through bind_rows()) are at the end of the dataset, and the header has a new strange name (as you can see from this image).

Moreover, if I use rbind() instead, the script launched through cronR just fail to compile because it catches an error with rbind.

Do you have any idea of what could be the problem? Thanks a lot!

P.S.: I work on a MacBook Pro late 2016, 8 Gb of RAM, with macOS Catalina installed.

Shiny app creating a cron job

I am trying to develop a shiny app that can create a cron job after doing some action.

I was wondering if the shiny user is able to do this operation (it works well with root).

I logged into my server with shiny user, opened an R session and typed the usual commands.
A cron job seems to be running, as I see it with cron_ls() but the data set that should be written every minut is not updated.

Provide support for waking up OS

Thanks for such a great package.
Any plans to integrate a way for waking the computer up if tasks where scheduled and the computer is asleep ?

cronR addin not working. Error on startup

My environment:
R - v4.0.3
Rstudio - v1.4.1717-3
Shiny - v1.7.3
ShinyFiles - v0.9.3
miniUI - v0.1.1.1

When I try to use the Addins -> Scehdule R scripts on Linux / Unix,

The console shows that it's trying to run the Addin. But fails.

cronR:::cron_rstudioaddin()

Even when I try to run the command, cronR::cron_rstudioaddin(RscriptRepository = Sys.getenv("CRON_LIVE", unset = getwd())), I still get the same error. I've also properly set the CRON_LIVE environment variable before running this command

Loading required namespace: shiny
Loading required namespace: miniUI
Loading required namespace: shinyFiles
Error in vec_as_location():
! ... must be empty.
✖ Problematic argument:
• call = call
Run rlang::last_error() to see where the error occurred.

cronR:::cron_rstudioaddin()
Error in vec_as_location():
! ... must be empty.
✖ Problematic argument:
• call = call
Run rlang::last_error() to see where the error occurred.

When I run rlang::last_error() I get the following

<error/rlib_error_dots_nonempty>
Error in vec_as_location():
! ... must be empty.
✖ Problematic argument:
• call = call

Backtrace:

  1. cronR:::cron_rstudioaddin()
  2. shiny::icon("cloud-upload")
  3. fontawesome::fa_i(name = name, class = class, ...)
  4. fontawesome:::get_icon_idx(...)
  5. fontawesome:::get_icon_idx_all_types(name = name)
  6. tibble:::[.tbl_df(...)
  7. tibble:::vectbl_as_col_location(...)
  8. vctrs::vec_as_location(j, n, names, call = call)

When I run rlang::last_trace(), I'm getting the following dump

<error/rlib_error_dots_nonempty>
Error in vec_as_location():
! ... must be empty.
✖ Problematic argument:
• call = call

Backtrace:

  1. └─cronR:::cron_rstudioaddin()
  2. ├─miniUI::miniPage(...)
  3. │ ├─htmltools::attachDependencies(...)
  4. │ ├─htmltools::tagList(...)
  5. │ │ └─rlang::dots_list(...)
  6. │ ├─shiny::fillPage(...)
  7. │ │ └─shiny::bootstrapPage(...)
  8. │ │ └─rlang::list2(...)
  9. │ └─tags$div(class = "gadget-container", ...)
  10. │ └─rlang::dots_list(...)
  11. ├─miniUI::miniTabstripPanel(...)
  12. │ └─miniUI:::buildTabset(list(...), "nav gadget-tabs", id = id, selected = selected)
  13. ├─miniUI::miniTabPanel(...)
  14. │ └─shiny::tabPanel(...)
  15. │ └─bslib::nav(title, ..., value = value, icon = icon)
  16. │ └─bslib:::tabPanel_(title, ..., value = value, icon = icon)
  17. │ └─bslib:::prepTabIcon(icon)
  18. └─shiny::icon("cloud-upload")
  19. └─fontawesome::fa_i(name = name, class = class, ...)
    
  20.   └─fontawesome:::get_icon_idx(...)
    
  21.     └─fontawesome:::get_icon_idx_all_types(name = name)
    
  22.       ├─alias_tbl[alias_tbl$alias == name, "name", drop = TRUE]
    
  23.       └─tibble:::`[.tbl_df`(...)
    
  24.         └─tibble:::vectbl_as_col_location(...)
    
  25.           ├─tibble:::subclass_col_index_errors(...)
    
  26.           │ └─base::withCallingHandlers(...)
    
  27.           └─vctrs::vec_as_location(j, n, names, call = call)
    
  28.             └─ellipsis::check_dots_empty()
    
  29.               └─rlang:::action_dots(...)
    
  30.                 ├─base (local) try_dots(...)
    
  31.                 └─rlang (local) action(...)
    

When scheduling to send out SMS CronR messes up the message encoding.

Hi! I've been passionately using CronR to schedule my scripts but recently I tried to use it to automatically send SMS and the encoding of my message gets messed up only when I schedule my script with cronR when I manually run the script the message reaches the recipient in the correct encoding. Is there any solution here that I'm missing?

Job does not work + addin window is inactive also

Hi Kevin,

I faced some problems with running cronR job. I installed cron and cronR on Google Compute Engine. I cannot run the job and I see no one as well as log file. Also, the window of cronR addin is inactive and I cannot take any action with it. Here is the code:
cron_add(paste0("Rscript ", normalizePath("gsc2bq.R")), frequency = "hourly", at="15:56")

My session info:


`R version 3.6.2 (2019-12-12) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 10 (buster)  Matrix products: default BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.5.so  locale:  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8      [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C              LC_PAPER=en_US.UTF-8       LC_NAME=C                   [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C         attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base       other attached packages: [1] shiny_1.4.0 cronR_0.4.0  loaded via a namespace (and not attached):  [1] Rcpp_1.0.3       crayon_1.3.4     digest_0.6.24    later_1.0.0      mime_0.8         R6_2.4.1         jsonlite_1.6      [8] xtable_1.8-4     magrittr_1.5     pillar_1.4.3     rlang_0.4.4      rstudioapi_0.10  fs_1.3.1         miniUI_0.1.1.1   [15] promises_1.1.0   shinyFiles_0.7.5 tools_3.6.2      httpuv_1.5.2     fastmap_1.0.1    compiler_3.6.2   pkgconfig_2.0.3  [22] htmltools_0.4.0  tibble_2.1.3`

Error butcode proceeds

Hi
I get this every time:
crontab: usage error: no arguments permitted after this option
But the cronR::cron_add() goes ahead and adds successfully in the system crontab as I confirm by crontab -l

cronR Rstudio addin fails

I have added the necessary packages and the Cron job scheduler window opens fine. I choose a script, launch date and launch hour. I also add a Job description. When I click Create job, I get the following messages in the Console

Listening on http://127.0.0.1:3294
Adding cronjob:

## cronR job
## id:   job_d1251755985c1afd78e975fd279c6b7b
## tags: 
## desc: Run PAmonitorscreenshot script
16 * * * * /Library/Frameworks/R.framework/Resources/bin/Rscript '/Users/gcn/Documents/workspace/PAmonitors/PAscreenshots.R'  >> '/Users/gcn/Documents/workspace/PAmonitors/PAscreenshots.log' 2>&1
crontab: tmp/tmp.2463: Operation not permitted

Suggestions on how to fix appreciated!

Unable to install cronR

Hello,

as per the title I am unable to install the package when I call install.packages("cronR"). I am getting a warning saying that this package does not exist for my version of R (I am using 4.2.1). I tried installing via github but that didn't work either. Thanks for your help in advance!

Librarys are not loaded from cron

Hi,

I am trying to execute a cron, but when it's executed I get this error:

Error in library(odbc) : there is no package called ‘odbc’
Execution halted

This library is working because if I execute manually the same script it works well.
I think that maybe is an error with and update of R version or something like that.

Can you help me please?

Thanks in advance.
David.

Path Name with Spaces

I seem to be experiencing similar issues with the cronR add-in for Unix/Linux as have been reported for the taskscheduleR Windows equivalent: I am not able to add jobs for scripts with a space in the path name.

As other users have pointed out (for taskscheduleR), I don't have access to changing the file path names in production due to IT. Would it be possible to fix this for cronR as was done for taskscheduleR?

Thank you in advance and thank you for a great add-in/package!

package was removed on CRAN

Package ‘cronR’ was removed from the CRAN repository.

Formerly available versions can be obtained from the archive.

Archived on 2021-09-02 for policy violation.

A summary of the most recent check results can be obtained from the check results archive.

Please use the canonical form https://CRAN.R-project.org/package=cronR to link to this page.

The package should not do cron_rm / cron_add / cron_clear / cron_load without manual confirmation by the user, nor in examples nor in unit tests, nor in the webapp.

Cronjob cant be deleted

First of all, thank you for the package!

I run in the following error, when attempting to delete a cronjob by id.

> cron_rm(id = "test2")
Removed 1 cron job.
new crontab file is missing newline before EOF, can't install.

In case the infos help:

  • i dont have multiple jobs with same id
  • i can add jobs without running in this error
  • jobs are also successfully executed

Before using cronR package i edited the crontab file "manually".
If i use the same command to manually check the file for missing newline i get a rather odd output:

rstudio@ip-199-99-99-6:~/dev $ sudo crontab -e
[sudo] password for rstudio:
73

So i dont see the jobs, but just "73". Is cronR saving the jobs in another file? What could i check to fix the error?

How to cancel the execution of a script sourced with a Cron?

Hello,

It didn't happen yet but I'm wondering as I can't seem to find a solution.
I use Rstudio, installed on a server. I often use CronR to execute some long scripts and be able to test out other stuff in the meantime.
I know how tu delete a cron job, but I didn't see any option to stop the execution of the script itself.
The situation I fear it as follow :
-Someone make a mistake in the script and put a loop without a break condition
-They run the script the script through a cron
-The script in now in an infinite loop and not shown

What would you do in this situation? Other than deleting the Cron job then rebooting the server (which I'd like to avoid) I have no idea.

Thanks in advance,

Schedule job every 15 min

I can see how you would use days_of_month or days_of_week to modify the frequency=daily for example, but is it possible in the script or (ideally) in the add-in to modify minutely to run every 15 minutes?

Adding a cron job with frequency set to 'minutely' and defining the 'at' parameter causes the job to run only the first time and not repeat

My stack overflow question on this issue can be found here https://stackoverflow.com/questions/68012286/cronr-runs-only-once-frequency-set-to-minutely-then-doesnt-run-anymore-after/68076777#68076777

I am currently using cronR version 0.4.2. The documentation when you do ?cron_add shows examples where the 'frequency' and the 'at' arguments are both given variables however I ran into this issue when I tried to do the same. After commenting out the 'at' argument, the script started running every minute as expected.

"Script_to_be_scheduled.R" - Create's and outputs a file:

library(data.table)
library(lubridate)

csv_table <- data.table(bla = sample(1:1000, size = 15) )

filepath <- "~/My-Local-Workspace"
filename <- paste0("automaticTable__", hour(Sys.time()), "_", minute(Sys.time()), "_", round(second(Sys.time())), ".csv")
filepath_full <-  paste0(normalizePath(filepath), "/", filename)

fwrite(csv_table, file = filepath_full  )

filepath_full
[1] "/home/redacted/redacted/My-Local-Workspace/Script_to_be_scheduled.R"

"Scheduler_test.R" - Create's and schedules the cron job to run every minute once a specified time is reached:

library("cronR")
filepath <- "~/My-Local-Workspace"
filename <- "Script_to_be_scheduled.R"
filepath_full <-  paste0(normalizePath(filepath), "/", filename)

commnd <- cron_rscript( filepath_full )

cron_add(command = commnd, 
         frequency = 'minutely', 
         id = 'This is the title', 
         at = '14:56', 
         description = 'My process 1', 
         tags = c('Algorithm_1'))

Compatibility with Project Template repo srtucture

Hi there,

I'm unsure if you have any plans to achieve this, but it would definitely help me schedule a la project template website

If this is of interest, some detail. I've toyed around with scheduling the 'initialise.R' script in the src folder. Looking at the logs generated, this appears to run and then sources the first of the munge scripts used to generate urls to scrape in the successive munge scripts. As you will see execution halts after munge script 1, which is perplexing as this is not a behaviour when manually executing the source file. Next steps for me are to try a cron job and failing that, go back to cronR but with a single script layout. Running R version 4.0.1 (2020-06-06) -- "See Things Now" on Mac. Below is the output from that log:

Project name: DSCA_course_catalogue_dev
Loading project configuration
Autoloading packages
Loading package: plyr
Loading required package: plyr
Loading package: dplyr
Loading required package: dplyr

Attaching package: ‘dplyr’

The following objects are masked from ‘package:plyr’:

arrange, count, desc, failwith, id, mutate, rename, summarise,
summarize

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Loading package: rvest
Loading required package: rvest
Loading required package: xml2
Loading package: selectr
Loading required package: selectr
Loading package: xml2
Loading package: stringr
Loading required package: stringr
Loading package: jsonlite
Loading required package: jsonlite
Loading package: tidyr
Loading required package: tidyr
Loading package: purrr
Loading required package: purrr

Attaching package: ‘purrr’

The following object is masked from ‘package:jsonlite’:

flatten

The following object is masked from ‘package:rvest’:

pluck

The following object is masked from ‘package:plyr’:

compact

Loading package: httr
Loading required package: httr
Loading package: httpuv
Loading required package: httpuv
Loading package: rlist
Loading required package: rlist
Loading package: gmailr
Loading required package: gmailr

Attaching package: ‘gmailr’

The following object is masked from ‘package:dplyr’:

id

The following object is masked from ‘package:plyr’:

id

The following object is masked from ‘package:utils’:

history

The following objects are masked from ‘package:base’:

body, date, labels, message

Autoloading helper functions
Running helper script: globals.R
Running helper script: helpers.R
Autoloading data
Munging data
Running preprocessing script: 01_GET_repo_urls.R
[1] "There are 30 URLs to scrape link from: "
[1] "https://github.com/datasciencecampus/access-to-services"
[2] "https://github.com/datasciencecampus/algorithmia-segment"
[3] "https://github.com/datasciencecampus/algorithmia-vegetation"
[4] "https://github.com/datasciencecampus/anomaly-detection"
[5] "https://github.com/datasciencecampus/awesome-campus"
[6] "https://github.com/datasciencecampus/clapp"
[7] "https://github.com/datasciencecampus/coding-standards"
[8] "https://github.com/datasciencecampus/coffee-and-coding"
[9] "https://github.com/datasciencecampus/coffee-and-coding-ldn"
[10] "https://github.com/datasciencecampus/community-visualizations"
[11] "https://github.com/datasciencecampus/consultation-analysis-nafw"
[12] "https://github.com/datasciencecampus/deploy-dash-with-gcp"
[13] "https://github.com/datasciencecampus/DSCA_advNLPpython"
[14] "https://github.com/datasciencecampus/DSCA_ARP"
[15] "https://github.com/datasciencecampus/DSCA_DSWR"
[16] "https://github.com/datasciencecampus/DSCA_ggplot-leaflet-map-training"
[17] "https://github.com/datasciencecampus/DSCA_Intro-R"
[18] "https://github.com/datasciencecampus/DSCA_introNLPpython"
[19] "https://github.com/datasciencecampus/DSCA_intropython"
[20] "https://github.com/datasciencecampus/DSCA_ML_theory"
[21] "https://github.com/datasciencecampus/DSCA_NLPWR"
[22] "https://github.com/datasciencecampus/DSCA_Stats4DS"
[23] "https://github.com/datasciencecampus/DSCA_Version-control-with-Git-Github"
[24] "https://github.com/datasciencecampus/DSCA_Version-controlled-RStudio-projects"
[25] "https://github.com/datasciencecampus/eclipse"
[26] "https://github.com/datasciencecampus/employmentProspects"
[27] "https://github.com/datasciencecampus/energy-efficiency"
[28] "https://github.com/datasciencecampus/finbins"
[29] "https://github.com/datasciencecampus/gcp-function-deployment"
[30] "https://github.com/datasciencecampus/google-mobility-reports-data"

Execution halted

Using www-data as a user

Hi there,
Thanks for a great package. I'm currently testing cronR. I'm trying to add a new cron on behalf of 'www-data' user from myuser account in RStudio

library(cronR)
f <- glue('/home/myuser/testfolder/crontesting.R')
cmd <- cron_rscript(f)
# cmd

cron_add(command = cmd, frequency = 'minutely', id = 'test1', user = 'www-data')

# cron_njobs()
# cron_ls()

But cron is added on behalf of myuser:

cron_ls(user='myuser')
## cronR job
## id:   test1
## tags: 
## desc: 
# 0-59 * * * * /usr/lib/R/bin/Rscript '/home/myuser/myfolder/crontesting.R'  >> '/home/myuser/myfolder/crontesting.log' 2>&1

And not for www-data user

cron_ls(user='www-data')
# No cron jobs available for user 'www-data'.

What could be the problem?
Thank you!

cronR retains Job identifier and Rscript repository path from last user

In RStudio Server the the cronR Addin can be used to schedule a task.
When scheduling a task it appears the following values are retained from previous scheduling actions.

  • Job identifier
  • Rscript repository path
    This is problematic with multi-user systems i.e. other users values are presented.
    I would not expect these fields to be populated by a value another user has entered when I execute the cronR Addin.

Steps to Reproduce:

  1. Open RStudio Server
  2. Click Tools > Addins > Browse Addins…
  3. Select cronR > Execute
  4. Schedule cronR task
  5. Open RStudio Server as different user
  6. Click Tools > Addins > Browse Addins…
  7. Select cronR > Execute
    Fields populated with values entered by first user

This was raised with RStudio support who advised the issue is with the cronR package.
_When we run this for the first time in a new session in a local RStudio Server Pro environment, we see the following output: run first time output
The image shows that the function starts a shiny app for the cronR UI, and does not use the RStudio Server Pro IDE UI.

One thing to note is that value in the launch, and log location seems to be stored somewhere. From the following screenshot, you can see the path loaded after starting a completely new session:
path loaded in a completely new session

The value above is one we updated in an old session. Somewhere the cronR package is storing this information. And we believe the package maintainers will have a better idea as to where the value is cached._

Environment
RStudio Server Pro Version 1.4.1106-5
Red Hat Enterprise Linux 8
cronR 0.4.2

Bad minute error when using env argument

When I try to feed my current environment variables to cron_add, as suggested by your documentation, like this:

library(cronR)
f   <- base::system.file("scripts/my_cron_job.R", package = "mypackage")
cmd <- cron_rscript(f)

cron_add(command = cmd,
         frequency = 'minutely',
         id = 'test1',
         description = 'Minute scrape',
         tags = c('lab', 'xyz'),
         env = Sys.getenv()) 

I get the following error:

"/var/folders/v6/8rv32yhn4cz0x_gnk0kvb8jr0000gn/T//RtmpA631WG/filea7f66a543048":32: bad minute
crontab: errors in crontab file, can't install

Simply removing the env argument, everything works fine. But I need to feed my environment variables in. Did I misunderstand your documentation/is what I am trying to do possible?

Using cronR on Google Compute Engine

Im trying to set up a cron on a VM with Rstudio, but I get the following error using the addin:

Adding cronjob:

cronR job
id: job_c87a93d2999d0e7323dc0936556f9bae
tags:
desc: I execute things
0-59 * * * * /usr/local/lib/R/bin/Rscript '/home/acceso/Capacitarte/AnalyticsDataUpload.R' >> '/home/acceso/Capacitarte/AnalyticsDataUpload.R' 2>&1
Warning: Error in system: error in running command
78: system
75: cron_add
74: observeEventHandler
3: shiny::runApp
2: shiny::runGadget
1: cronR:::cron_rstudioaddin

I also tried creating a cron_rscript and the using cron_add but same error. Any idea on how to fix it?

Thanks!

Run/test all cron jobs

Hi! Is it possible to run all existing (or selected) cron jobs with a command without having to edit their original timings? With cron_ls() I see all the cron jobs I have, but I don't find an easy way to those with a single command, without editing all cron jobs.

Something like this (over-simplified) would work:

cron_test <- function(){
  temp <- cronR::cron_ls()
  temp2 <- strsplit(temp, "\n")[[1]]
  temp3 <- temp2[grepl(">>", temp2)]
  cmnds <- gsub("  >>.*", "", gsub(".*/usr/local/lib64/R/bin/","",temp3)) #fix to match any case
  invisible(lapply(cmnds, system))
}

Cant delete jobs. All sub-lists in "choices" must be named.

Hello guys.
I've been using this super cool library for a while now and works like a charm.
But, today I had the following problem: when I opened the plugin window, and go to Manage existing jobs, I get the All sub-lists in "choices" must be named. error (see attachment for screenshot)

captura de pantalla 2018-06-06 a la s 12 15 20 p m

I tried manually removing the last created job with the cron_rm("id") function but it returns the Error in !to_keep : invalid argument type error.
Any suggestions?

R version 3.4.3
cronR version 0.4.0

modify task

Is there a way to modify a task, like taskscheduleR's modify argument to taskscheduler_create()?
I would like to run a task every 10 minutes, but the options for cron_add() are only "minutely", "hourly", "daily", "monthly", or "yearly".

cronR not working

@jwijffels Sorry about that. So yeah, my script won't run. Is there any way I can check if an attempt was made? What am I doing wrong? For reference, here are some screenshots of the inputs on the add-in.

1

2

Assuming I didn't do the crontab code incorrectly, that should have run at 1:30PM EST. But did not.

Scheduling every 2' between 7:30am and 5:30pm on workdays...possible?

Hi, first of all thanks a lot for the package: it works great.

I work with financial data and I was wondering if I could run a script regularly when markets are open, ie. every 2' between 7:30am and 5:30pm Monday to Friday?

I think I can do the "every 2'" and "Monday to Friday" but not sure about "from 7:30am to 5:30pm".

Is it possible to set up a job this way?

Thanks - Davide

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.