How do I watch a file for changes?

前端 未结 25 2812
孤街浪徒
孤街浪徒 2020-11-21 07:13

I have a log file being written by another process which I want to watch for changes. Each time a change occurs I\'d like to read the new data in to do some processing on it

25条回答
  •  爱一瞬间的悲伤
    2020-11-21 08:13

    Since I have it installed globally, my favorite approach is to use nodemon. If your source code is in src, and your entry point is src/app.py, then it's as easy as:

    nodemon -w 'src/**' -e py,html --exec python src/app.py
    

    ... where -e py,html lets you control what file types to watch for changes.

提交回复
热议问题