Node Cron start running at 0.00 minutes and then after 60 minutes

221 views Asked by At

i am using node-cron. what i want is when my program start node-cron should run the function and then wait for 60 mints and run the function but in real when i start the execution node-cron did'not run the function on start but after 59 mints . any help will be appreciated. thanks in advance

here is my code.

export const surrogate = async () => {
  cron.schedule("*/59 * * * *", scheduleFunction);
};

const scheduleFunction = async () => {
  console.log("Calling after 59 minutes");
};
1

There are 1 answers

0
Stock Overflaw On BEST ANSWER

Since you must call surrogate only once at start-up:

export const surrogate = async () => {
  scheduleFunction();
  cron.schedule("*/59 * * * *", scheduleFunction);
};