I am running a MEAN stack application and am struggling with proper implementation of a reoccurring task. I have added the following line to my server.js file:
require('./node_scripts/schedule/node_sched.js');
It then points to this file:
var schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
rule.minute = 57;
var notify = schedule.scheduleJob(rule, function(){
var notifyScript = require('../arrival_checker/arrival_main.js');
console.log('Ran notify script ' + new Date());
notifyScript;
});
The script runs one time successfully but it never runs again. Here are my questions:
- Is this the propper way to perform a scheduled task in a MEAN stack environment?
- How do I need to change this code so it will run every hour?