- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在开发一个调度多个 cron 作业的 Nodejs 应用程序。顺便说一句,当我尝试取消作业时出现错误。
情况如下。
node-cron
或 node-schedule
创建了多个 cron 作业。 类型错误:testJob.destory不是一个函数
你能帮我解决这个问题吗?
const cron = require("node-cron")
// cron jobs
let testJob1
let testJob2
let testJob3
async function startCronjobs(cronTimes) {
testJob1 = cron.schedule(cronTimes.testTime1, () => {
console.log("test 1 job")
}, {
scheduled: true,
timezone: "America/New_York"
})
testJob1.start()
testJob2 = cron.schedule(cronTimes.testTime2, () => {
console.log("test 2 job")
}, {
scheduled: true,
timezone: "America/New_York"
})
testJob2.start()
testJob3 = cron.schedule(cronTimes.testTime3, () => {
console.log("test 3 job")
}, {
scheduled: true,
timezone: "America/New_York"
})
testJob3.start()
}
async function destroyCronjobs() {
console.log("============= Destroy node-cron Jobs ================")
return new Promise((resolve, reject) => {
if(testJob1 !== undefined && testJob1 !== null) testJob1.destory()
if(testJob2 !== undefined && testJob2 !== null) testJob2.destory()
if(testJob3 !== undefined && testJob3 !== null) testJob3.destory()
})
}
module.exports.destroyJobs = destroyCronjobs
module.exports.startCronJobs = startCronjobs
const cronManager = require("./cronManager")
const express = require("express")
const router = express.Router()
router.post("/start", wrapper(async (req, res) => {
await cronManager.startCronjobs()
}))
router.post("/destroy", wrapper(async (req, res) => {
await cronManager.destoryCronjobs()
}))
最佳答案
您的代码中有拼写错误,您有 testJob1.destory()
但它应该是 testJob.destroy()
destroy()将被停止并完全破坏计划任务。
假设这是示例代码,因此它缺少 cronManager.startCronjobs()
的一些参数,并且该函数不会返回任何使用 await
的 promise
。
关于javascript - 销毁 Node cron 作业或取消 Node 调度程序作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55036349/
嗨,我想运行一个 cron 作业来在我的服务器上调用 PHP 脚本。 我正在使用 Cpanel 从我的网络主机,这些是选项: 分钟: 小时: 日: 月份: 工作日: 命令: 我真的很难将命令指向我的文
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
有没有办法配置supervisor每 X 秒运行一些命令(如 CRON)? 我看到了 eventlistener 和 TICK_ 事件的例子 [eventlistener:memmon] comman
如果 Cron 有一项作业计划在凌晨 2 点运行,另一项作业在凌晨 3 点运行,那么这些作业会受到夏令时的影响吗? 当时间向后移动一小时时,时间是否会直接从凌晨 2:59:59 变为凌晨 2:00:0
第一个示例 假设我有一份 CRON 工作 30 2 * * * .... 然后每次晚上 2:30(本地时间)都会运行。 现在假设我的时区是欧洲/德国,并且是 2017 年 10 月 29 日(夏令时
我想在不到一分钟的时间内(例如每 30 秒)在主机上运行一个命令,但我无权访问 ssh。我只有 .我不知道如何使用它进行一些黑客攻击以在不到一分钟的时间内运行代码。 EDIT1:在这个问题中,我的访问
我探索并发现在 quartz cron 表达式中: sec min hour day_of_month month day_of_week year, 我们可以提供 day_of_month 或 da
我试图弄清楚是否可以设置一个 cron 作业,将所有文件从我的服务器上的一个文件夹传输到另一个文件夹,然后从另一个文件夹中获取一组文件(随机选择的文件)并将其放入原来的文件夹中。如果有关于如何执行此操
我服务器上的一个驱动器最近损坏了操作系统。我能够恢复所有文件,但现在我有一个只有文件系统的备份驱动器;不可启动。我现在正在设置一个新服务器,并且需要设置旧的 cron 作业。有没有办法查看文件结构以查
我尝试了 http://docs.opscode.com/resource_cron.html#examples 给出的最简单的例子 cron "name_of_cron_entry" do
我注意到很多人在讨论 Gearman,它的调度功能使它能够将工作分配到其他服务器上。但是,我还没有看到与本地 cronjobs 的比较。 cron 和 Gearman 有什么区别? 最佳答案 如果您正
我需要在此运行一份工作 cron日程安排,但似乎我无法在一份声明中表达这一点。有没有办法在一个 cron 中得到这个陈述? 周一至周六上午 8 点 下午 2 点 谢谢。 最佳答案 你是对的。恐怕这是不
我正在尝试在 OVH 网络主机上设置 cron。 要执行的脚本位于: /home/[登录ftp]/www/script.sh 因此,我使用此设置在 OVH 界面上创建了一个 cron: 要执行的命令:
这是cron我试过的表达 0 0 0 */14 * ?它给出了以下时间表 开始时间:- Friday, September 8, 2017 1:25 AM 下一个预定:- 1. Friday, Se
你如何从命令行创建一个 cron 作业,以便它在 gnome-schedule 中显示一个名称? 我知道如何使用 crontab 创建一个 cron 作业。但是,我所有的工作都以空白名称显示。我想更好
我有一个由 cron 安排的工作:每小时从服务器弹出电子邮件。 但有时我不想等待 60 分钟来查看我的电子邮件。为此,我使用了一个脚本,该脚本运行与 crontab 中相同的命令。它本质上就像在计划运
我想要一个每 2 小时 10 分钟运行一次的计划的 cron 表达式,我期望的输出是2:004:106:20我试过 0 0/2 0/2 * * ?为此,输出是这样的2012 年 11 月 1 日星期四
我有一个执行 shell 脚本的 cronjob在我的 shell 脚本中我做了一个模块加载 tww/perl 但它给了我 module: command not found 我能做什么?我至少有 1
在 Jenkins 中,我们将 Poll SCM 计划设置为 * * * * * .但 Jenkins 建议 Do you really mean "every minute" when you sa
在 logrotate 联机帮助页中,他们说: “通常,logrotate 作为日常 cron 作业运行”。 这是否意味着 logrotate 使用 cron(或由 cron 执行)? 如果是这样,这
我是一名优秀的程序员,十分优秀!