I need to run cron once at a particular tine and after that have to stop the job
const cron = require("node-cron");
const SendEmail = (payload) => {
console.log("SENDING EMAIL", payload);
};
const ScheduleCronJob = (payload, cronTime) => {
console.log("ScheduleCronJob.........", cronTime);
const job = cron.schedule(cronTime, () => {
console.log("You will see this message every second");
SendEmail(payload);
job.stop();
});
return job;
};
const payload = { name: "sarath" };
const job = ScheduleCronJob(payload, "05 17 18 2 5");
job.start();
I am starting and stopping the cron
job this is not working fine for me. if i replace with "* * * * *" then it is working fine.
can anyone explain wher i did wrong