Home cron task
Post
Cancel

cron task

  • 我设置了一个定时任务来跟踪 cw 网站上的价格变化,代码是这样的:schedule.scheduleJob(“* * */5 * * *”, () => {…});。我预期这个任务每 5 小时运行一次。然而,很快我发现 record 函数频繁运行,大概每一秒一次。后来查阅资料后,才知道 ~~~ The cron expression * * */5 * * * breaks down as follows: First *: every second Second *: every minute */5: every 5 hours ~~~

  • For running the schedule every 5 minutes, the correct cron expression should be 0 */5 * * * *, which translates to:

At second 0 Every 5th minute Every hour

This post is licensed under CC BY 4.0 by the author.