4

Does node-schedule npm module spwan/fork new process or we have to do it ourself ?

var cron = require('node-schedule');
var cronExpress="0 * * * *";

 cron.scheduleJob(cronExpress, () => {
            //logger.info("Cron expression Rule "+Date());
            doSomething();
        });

Using the above piece of code will run the job on the same instance or spawn another process i.e node-schedule handles this?

Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33
  • 1
    It seems like it will only invoke the passed job function, see here: https://github.com/node-schedule/node-schedule/blob/master/lib/schedule.js#L175 – DevDig Nov 07 '16 at 09:27
  • 1
    Just by looking in the source-code I would say it runs on the same instance since there's no spawn or fork called. Also no `require('child_process');` – Molda Nov 07 '16 at 09:32
  • https://stackoverflow.com/a/51496511/5222115[enter link description here](https://stackoverflow.com/a/51496511/5222115) Refer above answer – murtuza hussain Aug 27 '18 at 13:45

1 Answers1

0

cron.scheduleJob(cronExpress, () => { shell.exec(node ../jobs/job1.js'); }) // you can use shelljs or childprocess doing some stuff, childProcess(https://nodejs.org/api/child_process.html)

isik_hi
  • 89
  • 5