skip to Main Content

I had a R script configured to run via cron every day at 10am

library(cronR)
cmd2 = cron_rscript("CargueDiario_RedcapCovid_ODS.R", rscript_log="/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log", log_append = T, log_timestamp = T)

cron_add(command = cmd2, frequency = 'daily', at = "10:00" , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")

cron_ls("FCVREDCAPCOVID_ODS_DIARIO")
## cronR job
## id:   FCVREDCAPCOVID_ODS_DIARIO
## tags: 
## desc: FCVREDCAPCOVID_ODS_DIARIO
0 10 * * 0,1,2,3,4,5,6 /usr/lib/R/bin/Rscript '/home/admonda/R/projects/contagios_covid_santander/CargueDiario_RedcapCovid_ODS.R'  >> '/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log' 2>&1

Now i need to change it so it runs twice a day (10:00 and 22:00). I have already deleted it from CRON and I would like to make sure this is the correct new command:

cron_add(command = cmd2, frequency = 'daily', at = c("10:00","22:00") , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")

2

Answers


  1. You still can use your original line, just change 10 to 10,22.

    0 10,22 * * * /usr/lib/R/bin/Rscript '/home/admonda/R/projects/contagios_covid_santander/CargueDiario_RedcapCovid_ODS.R'  >> '/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log' 2>&1 >/dev/null 2>&1
    
    Login or Signup to reply.
  2. cron_add(command = cmd2, frequency = 'daily', at = 'c(10,22)', days_of_week = '*', id = '...', description = '...')
    

    Or just use cron expression:

    cron_add(cmd, frequency = '0 10,22 * * *', id = '...', description = '...')
    

    source: https://www.rdocumentation.org/packages/cronR/versions/0.4.2/topics/cron_add

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search