How to make node-schedule work in Heroku?












4















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");
});









share|improve this question























  • 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
















4















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");
});









share|improve this question























  • 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














4












4








4








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");
});









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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












1 Answer
1






active

oldest

votes


















1














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()








share|improve this answer
























  • 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














Your Answer






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
});


}
});














draft saved

draft discarded


















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









1














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()








share|improve this answer
























  • 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


















1














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()








share|improve this answer
























  • 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
















1












1








1







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()








share|improve this answer













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()






share|improve this answer












share|improve this answer



share|improve this answer










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





















  • 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






















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents