Search code examples
node.jsservicenode-cron

How can i make a service in node js that will perform task for different users in different specific time that stored in Database


I want to make a service in nodejs that will perform some task for different users in different time. I have some idea about node-corn. But it do task in fixed time for one user i guess. Can i write any servic for multiple user in different time

const cron = require('node-cron');
cron.schedule("* 1 * * * *", function() {
    console.log("---------------------");
    console.log("Running Cron Job every one Hours");
});

Solution

    1. Create a job queue table/collection with a task activation field, You can use MongoDB or Mysql for that.
    2. Push items to it with appropriate props
    3. Develop a job scheduler (Can be a cron enabled AWS Lambda function) polls this table for new tasks & execute a task based on the activation time.