node.js - 基于日历选择的 NodeJs 作业调度程序

标签 node.js scheduler

我正在构建nodejs应用程序。这是我第一次在代码中使用作业调度程序。

我希望用户从日历(例如引导日期时间选择器)中选择日期和时间,以便在这些日期和时间在服务器上运行特定脚本。用户选择的时间表将保存在服务器上,并根据时间表在服务器上执行脚本。

我在网上搜索了一些库,例如议程、后来、 Node -cron、 Node 计划等。然后还有一个库Bull、Bee和Kue。

我很迷失从哪里开始。如果在 Node.js 作业调度方面有经验的人能够指导我同意我的用法,我将非常感激。这会节省我很多时间。

最佳答案

您可以尝试“node-schedule”的基于日期的作业调度。 引用: https://www.npmjs.com/package/node-schedule#date-based-scheduling

var Schedular = require('node-schedule');
var date = new Date(2018, 10, 27, 12, 25, 0);
let nodeScheduler = await Schedular.scheduleJob(date, async function () {
        console.log("Job started.");
        console.log('** do something **');
        console.log(`Job completed`);
    });

新日期中的位置:2018年10月(0-1月、11-12月)、27-日期、12-小时、25-分钟

关于node.js - 基于日历选择的 NodeJs 作业调度程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53492914/

相关文章:

c - sched_getscheduler(pid)返回的int值分别对应什么调度策略? [C]

node.js - sequelize 连接表,附加属性不起作用

node.js - 安装 Node.js 后出现 npm 错误 : Cannot find module 'es6-promisify'

java - 如何在QuartzDesk中手动添加Job Data Map?

multithreading - 为什么 Go 被认为是部分抢占式的?

java - Spring Cron 表达式 "*/5 * * * * ?"的含义

调度程序的 Cron 表达式

node.js - NestJS/Class-transformer @Type Discriminator 对象无法正确验证数据

node.js - 使用 fluent-ffmpeg 添加字幕

node.js - MongoDB没有更新