Cron packages for non-meteor project


#1

Tried these so far:

https://www.npmjs.com/package/node-cron
https://www.npmjs.com/package/cron

Checked some of the npm packages and they don’t seem to work for example:

var CronJob = require(‘node-cron’);

new CronJob.schedule(’* */2 * * * *’, function () {
console.log(‘You will see this message every 2 minutes’);
});

and expecting console log every 2 minutes to print, but both the node-cron and cron packages dont seem to fire correctly,
used percolate synched cron but from my understanding that package is only available for Meteor projects correct?

Anyone got good cron packages in npm that actually fires as expected say every 15mins at regular intervals for JS, but non-Meteor project? Cheers


#2

I’ve used https://www.npmjs.com/package/cron pretty extensively, and have never had a problem. You’ve posted your node-cron code, but can you post your cron code?


#3

Hi Huge


#4

In your first code sample

// Every 10 second regardless of time
new CronJob('10 * * * * *', function () {
console.log('You will see this message every 10 second');
}, null, true, 'America/Los_Angeles');

you’re not configuring your cron job to run every 10 seconds, you’re telling it to run every minute at the 10 second mark. If you want it to run every 10 seconds you would do something like

// Every 10 second regardless of time
new CronJob('*/10 * * * * *', function () {
console.log('You will see this message every 10 second');
}, null, true, 'America/Los_Angeles');

#5

Thanks Huge this makes sense.