Set Interval in Node.js vs. Cron Job? -
i'm learning node.js , set empty linux virtual machine , installed node.
i'm running function every minute
var request = require('request') var minutes = 1, the_interval = minutes * 60 * 1000 setinterval(function() { // run code }) }, the_interval);
and considering adding other functions based on current time. - (e.g. run function if datetime = sunday @ noon)
my question there disadvantages running set compared traditional cron job set up?
keep in mind have run function in node every minute anyways.
it depends on how strictly have adhere minute interval , if node script doing else in meantime. if only thing script run every x, consider having node script x instead, , scheduling using appropriate operating system scheduler.
if build , run in node, have manage lifecycle of app , make sure it's running, recover crashes, etc. executing once minute via cron more straightforward , in opinion conforms more unix philosophy.
Your Blog is amazing. If you want to know that HOW TO SETUP A CRON JOB then,
ReplyDeleteClick here for more information:
HOW TO SETUP A CRON JOB