Defining node agenda jobs for these use cases

664 views Asked by At

Hi I am using a node agenda to define a job in my app (https://github.com/rschmukler/agenda). I have two use cases that I do not know how to cover

1) I want the job to run every Tuesday or every Wednesday for example

2) I want the job to run every 5th or 10th of the month.

I know that node agenda uses human interval (https://github.com/rschmukler/human-interval) to interpret how often they want to run the jobs, but I see that it can only interpret units such as days, weeks, months etc. Any idea on how I could cover the two use cases I mentioned above?

For use case 1, I found that I can do something like this (from the agenda documentation):

var weeklyReport = agenda.schedule('Saturday at noon', 'send email report', {to: '[email protected]'});
weeklyReport.repeatEvery('1 week').save();
agenda.start();
1

There are 1 answers

5
aquint On

You can use cron format:

1) weeklyReport.repeatEvery( "0 0 * * 1,4")

Where 1 is Monday and 4 is Thursday

2) weeklyReport.repeatEvery("0 0 1,15 * *")

This will run on the 1st and 15th of the month