How to make node-schedule work in Heroku?
I am running jobs from the 'node-schedule' module.
On localhost everything works great but when I upload to production in Heroku it doesn't.
i have changed my timezone in the settings -> var config to TZ at Asia/Jerusalem
but it still doesn't work.
Any idea why? Uploading my code although I think it is something with Heroku, not the code. Currently updating every minute just to test it, usefully its once every 1.5 hours
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
node.js express heroku scheduled-tasks scheduler
|
show 7 more comments
I am running jobs from the 'node-schedule' module.
On localhost everything works great but when I upload to production in Heroku it doesn't.
i have changed my timezone in the settings -> var config to TZ at Asia/Jerusalem
but it still doesn't work.
Any idea why? Uploading my code although I think it is something with Heroku, not the code. Currently updating every minute just to test it, usefully its once every 1.5 hours
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
node.js express heroku scheduled-tasks scheduler
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48
|
show 7 more comments
I am running jobs from the 'node-schedule' module.
On localhost everything works great but when I upload to production in Heroku it doesn't.
i have changed my timezone in the settings -> var config to TZ at Asia/Jerusalem
but it still doesn't work.
Any idea why? Uploading my code although I think it is something with Heroku, not the code. Currently updating every minute just to test it, usefully its once every 1.5 hours
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
node.js express heroku scheduled-tasks scheduler
I am running jobs from the 'node-schedule' module.
On localhost everything works great but when I upload to production in Heroku it doesn't.
i have changed my timezone in the settings -> var config to TZ at Asia/Jerusalem
but it still doesn't work.
Any idea why? Uploading my code although I think it is something with Heroku, not the code. Currently updating every minute just to test it, usefully its once every 1.5 hours
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
node.js express heroku scheduled-tasks scheduler
node.js express heroku scheduled-tasks scheduler
asked Nov 22 '18 at 2:10
ContentopContentop
12310
12310
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48
|
show 7 more comments
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48
|
show 7 more comments
1 Answer
1
active
oldest
votes
I am successfully using cron jobs on Heroku and Azure with following code. I am using cron
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
add a comment |
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422962%2fhow-to-make-node-schedule-work-in-heroku%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am successfully using cron jobs on Heroku and Azure with following code. I am using cron
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
add a comment |
I am successfully using cron jobs on Heroku and Azure with following code. I am using cron
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
add a comment |
I am successfully using cron jobs on Heroku and Azure with following code. I am using cron
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
I am successfully using cron jobs on Heroku and Azure with following code. I am using cron
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
import { CronJob } from 'cron';
const doSomething = new CronJob(
'0 0 * * 1', //cron time
fnname, //replace with your function that you want to call
null, //oncomplete
false, //start flag
'America/Los_Angeles',// timezone
);
doSomething.start()
answered Nov 22 '18 at 4:15
shmitshmit
591411
591411
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
add a comment |
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
There is no need to set timezone on Heroku. The job run as per schedule and time zones are as per timezone defined at momentjs.com/timezone
– shmit
Nov 22 '18 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 '18 at 7:45
1
1
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
Its powers down only those dynos that are running under free tier. You canuse a service like uptime robot to ping those dynos intermittently that will keep them awake but this leads to fast consumption of free 550 dyno hours.
– shmit
Nov 22 '18 at 21:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422962%2fhow-to-make-node-schedule-work-in-heroku%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 '18 at 2:29
BTW changing your timezone on Heroku is only a visual change for the dashboard, I don't believe it actually reflects on the servers.
– dotconnor
Nov 22 '18 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 '18 at 2:36
I think you have to check where/how the node package gets its info. I guess from the servers scheduler, and when its not present then.....EDIT: I have just checked - it use cron.
– split
Nov 22 '18 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 '18 at 2:48