How can I tail a log file in Python?

前端 未结 12 2420
故里飘歌
故里飘歌 2020-11-22 10:50

I\'d like to make the output of tail -F or something similar available to me in Python without blocking or locking. I\'ve found some really old code to do that here, but I\'

12条回答
  •  没有蜡笔的小新
    2020-11-22 11:14

    If you are on linux you implement a non-blocking implementation in python in the following way.

    import subprocess
    subprocess.call('xterm -title log -hold -e \"tail -f filename\"&', shell=True, executable='/bin/csh')
    print "Done"
    

提交回复
热议问题