简体   繁体   English

如何立即执行节点计划作业并每30分钟重复一次

[英]How to execute a node-schedule job immediately and recurring after every 30 mins

I have written a nodejs program, and want to schedule it using node-schedule npm, recurring every 30 mins. 我已经编写了一个nodejs程序,并希望使用节点计划npm对其进行计划,每30分钟重复一次。 I have scheduled it using 我已经安排了使用

var nodeSchedule = require('node-schedule');
nodeSchedule.scheduleJob('* /30 * * * *',require('./devModules.js').runDev);

Instead of executing immediately it is going for a sleep of 30 mins and then executing every 30 mins. 它不是立即执行,而是要休眠30分钟,然后每30分钟执行一次。 How do I schedule it immediately and reoccur after every 30 mins? 如何立即安排并每30分钟重新出现一次?

Please help. 请帮忙。

I think node-scheduler does not support this and things like this can be done with setInterval but to use it with corn use "corn" module:- Cron npm 我认为节点调度程序不支持此功能,可以使用setInterval完成类似操作,但要与玉米一起使用,请使用“玉米”模块: -Cron npm

 var cronJob = require('cron').CronJob; var myJob = new cronJob('0 */10 * * * *', function(){ console.log(new Date().toLocaleString()); },function(){ },true); // true value will start it once you start cron job 

Let us know if it is helpful. 让我们知道是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM