每天午夜运行一次功能 [英] Running a function everyday midnight
本文介绍了每天午夜运行一次功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
walk.on('dir', function (dir, stat) {
uploadDir.push(dir);
});
我正在使用Node,我需要使此功能每天在午夜运行,这有可能吗?
I am using Node, and i need make this function run everyday at midnight, this is possible?
推荐答案
我相信节点时间表包将满足您的需求.通常,您希望所谓的 cron 安排和运行服务器任务.
I believe the node-schedule package will suit your needs. Generally, you want so-called cron to schedule and run your server tasks.
具有节点计划:
import schedule from 'node-schedule'
schedule.scheduleJob('0 0 * * *', () => { ... }) // run everyday at midnight
这篇关于每天午夜运行一次功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文