Search code examples
pm2

How to make a task job with PM2?


I want to make a repeatable job to send mail every 15 minutes taking data from a database table. In node js I can create the job but through PM2 I don't understand where to place the code and how it works.


Solution

  • thank you for your answer; i do it in this way and just set the email

    1.

    npm install node-crontab
    
    var crontab = require('node-crontab');
    
    var jobId = crontab.scheduleJob("*/15 * * * *", function(){ 
    
        //This will call this function every 15 minutes
    
        console.log("It's been 15 minutes!");
    
    });