DEV Community

Cover image for How to create a Task Scheduler in NodeJS

How to create a Task Scheduler in NodeJS

Andre de Vries on March 16, 2019

Wes Bos posted a really useful video explaining how to scrape data from the web with NodeJS. In his second video he explained how to setup...
Collapse
 
daveskull81 profile image
dAVE Inden

Great post. It is a nice example of getting a scheduled app up and running. I especially like the link out to the crontabguru resource. That will be very helpful in understandingand those statements for this and other cron jobs. I also like the use of esm. I have been meaning to bring that into some of my projects to be abel to use import and export statements.

Collapse
 
florinpop17 profile image
Florin Pop

Very nice article! ๐Ÿ‘ I've learned about esm. Never used before, wondering why? ๐Ÿค”

Collapse
 
thesuhu profile image
The Suhu

if i set scheduller every 1 minute, but task finish more than one minutes, how to prevent from overlaping job?

Collapse
 
jay97 profile image
Jamal Al

Question: the script got be ruining all the time in order for this to work right? So if I turn off my PC, it's gone. Or is it written to the OS crontab?

Collapse
 
entrptaher profile image
Md Abu Taher

You can use a package manager like pm2 to run it forever in background.

Collapse
 
andre347 profile image
Andre de Vries

Good question! But yes if you turn your machine off the cron job will stop. Iโ€™ll have a look if I can find an npm package that actually writes to the crontab.

Collapse
 
mrdiez73 profile image
mrdiez73

Great post bro, love it simple and easy to understand.

Thx!!!

Collapse
 
dishantpandya profile image
Dishant Pandya

Hi! Can you suggest a solution for distributed scheduling for scalable microservices.