I'm creating an API that runs a function once every 30 seconds on demand from the client. The problem is that using Cron and Node-schedule execute all the jobs at the same time every 30 seconds regardless of the time the request came. E.g every xx:00 and xx:30 xx 1:00. The behavior that I'm looking for is to execute it with an interval depending on the request time, so if it came at xx:05 then it will execute it at xx:35 xx 1:05 and so on.
the function I'm using is :
const schedule = require('node-schedule');
schedule.scheduleJob(jobID, "*/30 * * * * *",()=> {JobFunction(jobID)})
CodePudding user response:
I think you can do that with bree
package which permit you to specify a start date ant an interval: https://github.com/breejs/bree#job-interval-and-timeout-values
But i have not try this