Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining node agenda jobs for these use cases

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();
like image 682
es3735746 Avatar asked Jun 23 '15 07:06

es3735746


People also ask

What is Agenda job?

Agenda jobs can be scheduled also using cron syntax. Agenda is easy to use and it is easier to track scheduled jobs and tasks by viewing scheduled, for example: DB collection view. I hope you use Agenda.

What is the technique used to schedule jobs to specific nodes?

node-cron syntax It is a package used to schedule tasks (functions or commands) in Node. js. Its name is derived from the Greek word 'Chronos' meaning time. These tasks can be scheduled to either run once or repeatedly.

What is the work of node?

Node. js is a JavaScript runtime environment that achieves low latency and high throughput by taking a “non-blocking” approach to serving requests. In other words, Node. js wastes no time or resources on waiting for I/O requests to return.


1 Answers

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

like image 100
aquint Avatar answered Oct 17 '22 01:10

aquint