node.js cron命令未执行

发布于 2025-02-08 18:44:49 字数 243 浏览 1 评论 0原文

控制台窗口中什么都没有。 但是每秒应执行的命令未执行。 这是我的代码。

const cron = require('cron');

new cron.CronJob('* * * * * *', () => {
  console.log("Execute")
},
  null, true, "Asia/Seoul"
).start()

Nothing appears in the console window.
But the command that should be executed every second is not executed.
This is my code.

const cron = require('cron');

new cron.CronJob('* * * * * *', () => {
  console.log("Execute")
},
  null, true, "Asia/Seoul"
).start()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2025-02-15 18:44:49

尝试将cronjob定义为像

const job = new cron.Cronjob()

btw这样的句子。如果将第四个参数设置为true,则无需调用start()方法。

Try to define a cronjob into a const like

const job = new cron.Cronjob()

Btw. you don't need to call the start() method if you set the fourth argument to true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文