Does agenda/cron support repeat for this scenario? example : repeat a job every 2 week on monday and tuesday, i am able to repeat a job every 2 week but not a particular days, if yes what will be the expression of time interval. Both week and days can be dynamic. Thanks
Asked
Active
Viewed 1,524 times
1
-
Useful link to [construct cron sentences](https://crontab.guru/#0_8_*/1,*/14_*_1,2). The cron syntax in that link is the closest I could get to what you are describing. This link also describes what you are constructing, very handy – SBylemans Oct 05 '18 at 06:32
1 Answers
2
If you look at the documentation agenda provides the ability to schedule with cron
syntax. So for example something like this:
await agenda.every('*/3 * * * *', 'delete old users');
Should set agenda to run every 3 minutes.
In your case it is just a matter of finding the correct cron string. Like this for example:
0 0 */15 * 1-2
At 00:00 on every 15th day-of-month if it's on every day-of-week from Monday through Tuesday.
await agenda.every('**0 0 */15 * 1-2**', 'do your thing');
Try it and see if it does what you would need.

Akrion
- 18,117
- 1
- 34
- 54