我已经为每一分钟创建了crone作业
import * as schedule from "node-schedule"
schedule.scheduleJob('* * * * *', async () => {
console.log("running every minute")
});上面的每一分钟都能完美地工作。同样,我的任务必须每小时执行一次。我试过了,如下所示
schedule.scheduleJob('0 0 */1 * *', async () => {
console.log("running every minute")
});但不幸的是,它并不是每小时都像预期的那样工作。我还有什么遗漏的吗?
发布于 2021-02-10 23:21:37
我想你想要"0 */1 *“。你也可以使用这个很棒的网站来确保你的crontab是正确的:https://crontab.guru/
发布于 2021-02-10 23:34:16
根据node-schedule,第三个*是小时
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)每隔一个小时试一试
schedule.scheduleJob('0 0 */1 * * *', async () => {
console.log("running every minute")
});发布于 2021-02-10 23:43:34
每小时应为:
schedule.scheduleJob('0 0 */1 * * *', async () => {
console.log("running every hour")
});https://stackoverflow.com/questions/66139676
复制相似问题