Con*_*top 7 scheduler heroku scheduled-tasks node.js express
我正在从“节点调度”模块运行作业。
在本地主机上一切正常,但是当我在 Heroku 中上传到生产时却没有。
我在亚洲/耶路撒冷的设置 -> var config 中将时区更改为 TZ,但它仍然不起作用。知道为什么吗?上传我的代码,虽然我认为这是 Heroku 的东西,而不是代码。目前每分钟更新一次只是为了测试它,有用的是每 1.5 小时一次
const schedule = require("node-schedule");
const needle = require("needle");
let j = schedule.scheduleJob("* /1 * * * *", function() {
needle.put("https://myserver.herokuapp.com/myendpoint");
});
Run Code Online (Sandbox Code Playgroud)
我使用以下代码在 Heroku 和 Azure 上成功使用了 cron 作业。我正在使用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() Run Code Online (Sandbox Code Playgroud)