i want to use node-schedule , i get information from Data Base every day , and for each item i want to do some thing at special time. this is my code :
users.forEach(function(users_entry){
if(err){
console.log(err);
}
else{
var date = new Date(2014, 11, 29, 11, 45, 0);
schedule.scheduleJob(date,
function(){
console.log('The world is going to end today.');
});
}
});
but above code doesn't run at mentioned time and works all the time. what is problem?
Node Schedule is a flexible cron-like and not-cron-like job scheduler for Node. js. It allows you to schedule jobs (arbitrary functions) for execution at specific dates, with optional recurrence rules. It only uses a single timer at any given time (rather than reevaluating upcoming jobs every second/minute).
Scheduling a Simple Task with node-cron Input the following code into the index. js file to create our simple task scheduler: const cron = require("node-cron"); const express = require("express"); const app = express(); cron. schedule("*/15 * * * * *", function () { console.
The node-cron module is tiny task scheduler in pure JavaScript for node. js based on GNU crontab. This module allows you to schedule task in node. js using full crontab syntax.
i changed my code and used cron. https://www.npmjs.org/package/cron
it works very well :)
var CronJob = require('cron').CronJob;
new CronJob('* * * * * *', function(){
console.log('You will see this message every second');
}, null, true, "America/Los_Angeles");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With