How to make node-schedule work in Heroku?
up vote
3
down vote
favorite
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
up vote
3
down vote
favorite
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 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 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 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 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48
|
show 7 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
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 at 2:10
Contentop
226
226
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 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 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 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 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48
|
show 7 more comments
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 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 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 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 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 at 2:29
seems like the scheduler is a add on: devcenter.heroku.com/articles/scheduler
– split
Nov 22 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 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 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 at 2:36
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 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 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 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48
|
show 7 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 at 21:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 at 21:44
add a comment |
up vote
1
down vote
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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 at 21:44
add a comment |
up vote
1
down vote
up vote
1
down vote
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 at 4:15
shmit
44239
44239
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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 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 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 at 4:23
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 at 7:45
How does this work since heroku powers down idle nodes?
– Notflip
Nov 22 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 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 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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 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 at 2:32
This is not the add on scheduler from Heroku. It's a node package on npm
– Contentop
Nov 22 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 at 2:39
Ok so if uses cron is should work right?
– Contentop
Nov 22 at 2:48