0

I am attempting to set up a task using node-cron and shelljs to run a js file with node. Am I setting this up correctly?

const cron = require('node-cron');
const shell = require('shelljs');

cron.schedule('0 0 0 * * *', () => {

    console.log('Task started');

    if (shell.exec("NODE_ENV=production node /opt/ec2-user/services/D3/script.js >> /opt/ec2-user/logs/script.log").code !== 0) {

        shell.exit(1);

    } else {

        console.log('Task completed');

    }

}, true);
Nick
  • 466
  • 1
  • 6
  • 12

0 Answers0