Nodejs scheduling question?

I am try to add feature where user add a remainder timer to a particular task and when that times comes my node server sends a email to user about his/her pending task how do I implement it in nodejs I don’t have any Idea, please help?


Hello @priyanshushrama709
I think you need to read about node-cron. It is a node.js task scheduler.
You can start from here

Great suggestion.

Store your notifications in a database (or something similar) and then have the cron job run every minute and check the db for any notifications that need to go out.

Or just fork a new process each minute (or however often you want to check) and have that process run the db check and send out the emails. I’m not a backend node guy, so ‘fork’ might not be the correct terminology here, but I think you get my point.

Yeah I try this,

const cron = require("node-cron");
const shell = require("shelljs");

cron.schedule("* * * * * *", () => {
    console.log("scheduler is running...");
    // console.log("shell.exec('dir').code: ", shell.exec('dir').code)
    if (shell.exec('node src/helloworld.js').code !== 0) {
        console.log("Something went wrong");

this is my code for corn job.
But my problem is I take date to user through input field but I don’t know How do I use date to the node-corn and date will vary. mean: user add today date to a task then to another task user will add tomorrow date. In my app multiple task had multiple dates and multiple users with multiple tasks.

nothing interesting Nodejs scheduling question?

It’s cron as in ChRONological, not corn.

Anyway, cron is interval-based (repeat task every {t}), whereas I think you want time-based (do task at {t}).

There are lots of packages to help with this, node-schedule - npm seems popular (I can’t vouch for quality)