Reputation: 55
I would start my schedule whenever my server starts, On cronjob I use @reboot to schedule it, but seems this feature doesn't work on node-cron.
cron.schedule('@reboot', () => {
console.log('will execute at reboot');
});
Upvotes: 1
Views: 500
Reputation: 200
I have the same issue, it's impossible to do with "node-cron" lib. But you can resolve it, by another ways. When u start schedule job in the first time:
And you need some controller for checking "if task already done".
var cron = require('node-cron');
var task = cron.schedule('* * * * *', () => {
//check if current date != date from DB/local file => start the job
});
Upvotes: 1