Node.js setTimeout for 24 hours - any caveats?

后端 未结 3 1750
旧巷少年郎
旧巷少年郎 2020-12-20 14:15

Simple question, I want to set 24 or 12 hours timeout in Node.js to periodically (once or twice a day) check some db data and clean suspicious garbage, if any.

3条回答
  •  我在风中等你
    2020-12-20 15:07

    There should not be any problem at all, but in my opinion it is just better to do this thing with a OS cron job. This will use the OS timer, will call your node app; that will be clear to everybody, even to the one who has never seen node or JavaScript in action. Also it will automatically protect you from long-term memory leaks because your app will be killed after each iteration.

提交回复
热议问题