nodejs如何定时不停的向某个文件写入,比如每隔2s向log.txt.文件写入一段文本,写入的代码如下:
想实现一个后台不停的写入log,在网页循环的展示log.txt的内容。
怪我咯2017-04-17 16:21:20
Loop: infinite loop setTimeout
Recursive: setTimeout recursive
setInterval timing
ringa_lee2017-04-17 16:21:20
If you want to complete this loop operation without accessing the nodejs program through the command line or browser, you can try node-schedule, a scheduled execution module of nodejs, host the project in the background using pm2, and then use the scheduled module Just execute the logic code once in 2S