Keep my cron jobs and execute them even if my node server is rebooted

I have my application in node js and I want them to run at the scheduled time
But the problem is that if my server crashes / stops / restarts, these scheduled tasks are not saved and not executed.
In addition, all my tasks are planned and completed using only one process, but I want several processes to do this work.
I want all my workstations to be saved and executed, even if my node server is restarted, or better to execute it, even if my server is not running. The agenda is the use of mongoDB, which I do not want to use.
Node Specialist - Cannot save cron jobs

  var ctab = require('crontab'); ctab.load(function(err, crontab) { var job = crontab.create('* * * * * *'); var jobs = crontab.jobs(); crontab.save(function(err, crontab) { }); }); 

code>

+5
source share
1 answer

If you use MySQL, you can try with this npm package

In other cases, you need to create your own solution. In this case, I created a collection / table to store the state and schedule rules. Then, if the service crashes or reboots, you can get all the schedules from the database and restart them again from your app.listen event.

+2
source

Source: https://habr.com/ru/post/1246929/


All Articles