Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomazweiss opened this issue Apr 4, 2024 · 2 comments
Open

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

tomazweiss opened this issue Apr 4, 2024 · 2 comments

Comments

@tomazweiss
Copy link

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
Copy link
Collaborator

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

@asadow
Copy link

asadow commented Oct 28, 2024

In my case, the script ran every Monday. Best we change it to 0 X X * *? Likewise yearly could be 0 0 1 1 *. These would be more reliable across cron implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants