I am trying to run a test cron job in my node.js app (one just for this job) but it is not console.log()
like it should be. It should console.log()
every 10 seconds but it won't.
This is my only file in my directory/app other than package.json file and node_modules directory.
The code is here:
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
mongoose = require("mongoose"),
cron = require("node-cron");
mongoose.connect("mongodb://localhost/asset-management-v1");
// mongoose.connect("mongodb://localhost/yelp_camp_v10");
app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine", "ejs");
app.use(express.static(__dirname + "/public"));
app.use(function(req, res, next){
res.locals.currentUser = req.user;
next();
});
var task = cron.schedule('10 * * * *', function() {
console.log('immediately started');
}, false);
task.start();
My end goal is to check a mongodb collection
then look at the objectID
of each and if the objectID
time stamp is older than 10 days to send out an email using nodemailer
. If you see anything other than the thing causing the console.log
to fail please point it out so I don't have to come back and bother you all more.