Issue
I am using this cron job package: https://www.npmjs.com/package/cron
It works fine on my laptop (executes events at certain times properly). However, the cron jobs won't run on my AWS Ubuntu server. Does anyone know if there's additional configuration I need to make it work on AWS Ubuntu? Here's my code:
var CronJob = require('cron').CronJob;
//Server
app.listen(process.env.APP_PORT, function() {
var job = new CronJob('0 35 0 * * *', function() {
console.log('job runningggg');
}, function () {
console.log('job done!');
},
true
);
job.start();
Solution
Double check the server timezone. It probably run but just at different timezone as yours.
Better use this example to check if it's working properly. The example prints every second which make timezone different doesn't matter.
var CronJob = require('cron').CronJob;
new CronJob('* * * * * *', function() {
console.log('You will see this message every second');
}, null, true, 'America/Los_Angeles');
Answered By - Tuan Anh Tran