如何在每天晚上 11:00 在节点 js 中运行 API GET 调用

Sha*_*thi 2 javascript cron schedule crontab node.js

我在节点 js 中有一个 aws API GET 调用。

http://localhost:3000/amazon/api

我在此调用中提到了必要的功能。我想每天晚上 11:00 使用 node js 运行此调用。我浏览了cron and other scheduling包裹文件。有点混乱。

dun*_*all 5

您可以使用node-schedule模块来安排特定时间的任务。

每天上午 11 点的简单示例可能如下所示:

var schedule = require('node-schedule');

var j = schedule.scheduleJob('* * /11 * * *', function(){
  console.log('Run your process here');
});
Run Code Online (Sandbox Code Playgroud)