I use the cron library in NPM.
I want to make events for users, that create jobs that are expected to be executed in a month after the event.
Let's say that this is my code:
function userSignedUpEvent(user) {
var today = new Date();
today.setDate(today.getDate() + 30);
let cronSignature = `${today.getMinutes()} ${today.getHours()} ${today.getDate()} ${today.getMonth()} *`
let reminderJob = new CronJob(cronSignature,
() => {
user.sendEmail("It has been a month since you joined us!");
}, null, true, "Asia/Jerusalem");
}
The problem is that if the server is shut-down at the exact time of the cron-signature, the code will never be executed.
Is there a way in my case to save these jobs and sign them again whenever the server is up again?
Theoretically, I can save their signatures in my Database and implement that by myself, but I want to be sure there isn't a driven method to do it.