4 ms·
I recently had some smallen private projects and I reasearached and tried out a lot of services. I needed cron jobs to run Node.js scripts properly. My use cas
by smartinson 4y ago
I recently had some smallen private projects and I reasearached and tried out a lot of services. I needed cron jobs to run Node.js scripts properly.
My use cases have been:
- Web Scraping of some websites to check stock availability of a product (4 times a day).
- Web Scraping of a website to get an apppointment at a specific citizen office (every 5 seconds). If success then send a Telegram Chat Bot message to me.
The second use case was a bit tricky, because my IP was kicked frequently from the server, I tried out what the sweet spot timing for the ping was and my setup (all jobs with different IPs) was the following:
1. setup on my Raspberry Pi in combination of the package PM2 (PM2 is a daemon process manager that will help you manage and keep your application online 24/7)
2. setup on Render (https://render.com/ https://render.com/)
Advantage here was the very convinient, quick and easy setup. I was able to link my Github Repository to it and the Cron Job would re-build the program automatically whenever a new master version on GitHub was available.
I used an in-memory TypeScript job scheduler library in my project that repeatedly executes given tasks within specified intervals of time (e. g. "each 5 seconds") until 7 PM and I let the scron job service execute the script again at 7 AM in the morning.
Debug Print Console inclusive.
3. setup on EvenNode (https://www.evennode.com/docs/cron-jobs https://www.evennode.com/docs/cron-jobs)
Here the upload of my node.js script was done via FileZilla to the FTP-Server of EvenNode. Linkage to GitHub Repository is also possible but since I am not that familiar with the private key setup at GitHub I chose the FTP-Server option.
I used an in-memory TypeScript job scheduler library in my project that repeatedly executes given tasks within specified intervals of time (e. g. "each 5 seconds") until 7 PM and I let the scron job service execute the script again at 7 AM in the morning.
Debug Print Console inclusive.
Both online Service were very cheap, paid cents only. The Raspberry Pi solution was for free (only energy consumption).
I can highly recommend render.com and evennode.com for cron jobs.