Schedule Repeatable Jobs using bull.js By providing time in repeat rules

5.9k views Asked by At

I'm currently using bull js to create an api that schedules a job according to inputted time. currently I'm able to do this using crone expression if the time input is in the format of 'YYYY-MM-DD HH:mm". The only problem is that if I want to schedule a job that will run daily I have to write some logic to get time from the inputed time. My question is whether I can specify the repeat rules using a date input as it is done in node-schedule. in short, am looking for the equivalent of the following node-schedule implementation in bull.

var date = new Date(2012, 11, 21, 5, 30, 0);
var j = schedule.scheduleJob(date, function(y){
  console.log(y);
}.bind(null,x));```
1

There are 1 answers

0
Peter On

Based on the documentation, repeating tasks/jobs are handled using cron syntax:

paymentsQueue.process(function(job) {
  // Check payments
});

// Repeat payment job once every day at 3:15 (am)
paymentsQueue.add(paymentsData, { repeat: { cron: "15 3 * * *" } });