Reputation: 1014
I have this script using the npm module node-shedule
. I think I set it to run every 6 hours but it runs for an hour when the hour is 0,6,12,18. it only may run once. I could dirty fix it with a bool, but that ain't my style.
a cronjob in Linux is not an option either, it needs to run cross-platform
let schedule = require('node-schedule');
let j = schedule.scheduleJob('* */6 * * *', function() {
do smt
});
Upvotes: 4
Views: 1246
Reputation: 504
You have to do:
let schedule = require('node-schedule');
let j = nodeSchedule.scheduleJob('0 0 */5 * * *', function() {
do smt
});
It will run in the second 0 minute 0 every 6 hours. They use this format
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, optional)
Upvotes: 1
Reputation: 1518
This will run every minute. Change cron schedule to 0 */6 * * *
, to only run it when the minute is 0.
Upvotes: 1