user16891328 user16891328 - 4 months ago 12
Node.js Question

Run node script from within a node script

I would like to use node-schedule to run a certain node script at a certain time. Can I do something like this in node.js?

var schedule = require('node-schedule');

var j = schedule.scheduleJob('00 00 22 * * *', function () {
console.log('Running XX node.js script ...'); + '\\XX.js', function (err) {
if (err) throw err;

Not sure if something like


You have several options, all of which are listed in the docs for child_process. Briefly:

  • child_process.exec spawns a shell
  • child_process.fork forks a node process
  • child_process.spawn spawns a process