bnosac / cronR

A simple R package for managing your cron jobs.
Other
288 stars 38 forks source link

monthly job runs only if the specified day of month is Monday #67

Open tomazweiss opened 6 months ago

tomazweiss commented 6 months ago

Thank you for this package. I've found a bug when adding a monthly job. The following code produces a cronjob with schedule 0 6 4 * 1 which will run only if the fourth day of the month is Monday:

library(cronR)

cron_add(command = 'echo test', 
         frequency = 'monthly', 
         at = '06:00', 
         days_of_month = 'fourth',
         id = 'test job',
         dry_run = TRUE,
         ask = FALSE
         )

Result:

Adding cronjob:
---------------

## cronR job
## id:   test job
## tags: 
## desc: 
0 6 4 * 1 echo test

Workaround:

cron_add(command = 'echo test', 
         frequency = '0 6 4 * *', 
         id = 'test job',
         dry_run = TRUE,
         ask = FALSE
         )

Result:

At your own risk: will set the cron schedule as is: '0 6 4 * *'
Adding cronjob:
---------------

## cronR job
## id:   test job
## tags: 
## desc: 
0 6 4 * * echo test
jwijffels commented 6 months ago

Yes, that 1 in 0 6 4 * 1 is set here: https://github.com/bnosac/cronR/blob/master/R/cron_add.R#L151