简体   繁体   中英

How to set node-cron to run in 12 hours

I wish to schedule a task in my node.JS project to run in 12 hours from the time of schedule. I tried using 0 */12 * * * but it can only run at the 12th hour. How to do please?

You can give a try to Bull.js . I never used it for scheduling task (only one task after xx minutes). But according to their documentation, you can schedule/repeat a task.

Example code:

paymentsQueue.process(function(job){
    // Check payments
});

 // Repeat payment job once every day at 3:15 (am)
 paymentsQueue.add(paymentsData, {repeat: {cron: '15 3 * * *'}});

Link to doc

Quite easy to use as it follows cron expression descriptor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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