节点cron,每半夜运行一次
我想在午夜每天运行cron作业。 为此,我正在使用
0 0 0 1-31 * *
但它不适合我。 我正在使用节点cron 。 请build议有效的格式。
你不需要设置所有的字段。 设置前三个,它会照顾每天午夜运行
0 0 0 * * *
这很简单….
以下是每天早上12点运行crone工作的代码。
var job = new CronJob('0 0 0 * * *', function() { //will run every day at 12:00 AM })
这是:
var CronJob = require('cron').CronJob; var job = new CronJob('00 00 00 * * *', function() { /* * Runs every day * at 00:00:00 AM. */ // DO SOMETHING }, function () { /* This function is executed when the job stops */ }, true /* Start the job right now */ );