4

I have some scheduled tasks in my node app. These are scheduled using node-cron. I just want to confirm onething. By using node-cron, will these tasks be executed in parallel? I am aware that node.js is single threaded. By using node-cron, will I be able to run sub tasks in parallel?

If node-cron does not spawn child processeses for scheduled jobs, is there any library that would help me to achieve this?

I have tried this code. Once the scheduled task is executed, the other scheduler is never get executed. So apparantly node-cron does not spawn child processes.

let cron = require('node-cron');

cron.schedule('* * * * *', ()=>
{
    console.log("Every minute", new Date());
});
cron.schedule('*/2 * * * * *', ()=>
{
    while (true) {
        console.log("Hello..... from scheduler");
    }
});
Ganesh Kumar
  • 3,220
  • 1
  • 19
  • 27

0 Answers0