Setup cron in Node.js || Autorun || Cron Job
Hello fellow developers.... Only Namaste ... because its COVID-19 time. :-p
So... today, we are going to show you one another topic ... which called Cron. While development, may be there is any need that some snippet may need to run after some specific interval. So this can be done using the Cron ... we can say that Cron Job.
First... let's talk about what is cron ?
And the one liner explanation is ... Cron is the software utility, which is time-based job schedular. That's it. For more information you can go to wiki
Now let's jump to code now.
Example:
- You have one function (checkStatus)
- You want to run after every 30 seconds.
So for this implementation we will be using one npm named Cron
Hello..
So here you can see that... we are using only one file.. Next you might have one quetion in your mind that, how we will run this file ?
It is very simple... put this file in any folder > Open terminal at that location > run 'npm install cron' > run 'node file_name.js'
Q: What is the first argument of cron.job method ?
A: That is the cron range, which will say your function at what interval it will be executed. [ more ]

0 Comments
New Comment on MEAN Stack ...