V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
licoycn

通过系统级的命令(如`tail -f`)来实时监控文件变动

  •  2
     
  •   licoycn ·
    Licoy · Dec 2, 2021 · 1439 views
    This topic created in 1608 days ago, the information mentioned may be changed or developed.

    最近在写一款微型日志监控,奈何没有找到好的监听文件变动的依赖,于是就自己写了一个,主要用法类似于 tail 命令,如:

    tail -100f system.log
    

    windows 下就是

    Get-Content -Path system.log -Tail 100 -Wait
    

    开源地址: https://github.com/Licoy/stail

    fighterhit
        1
    fighterhit  
       Dec 12, 2021
    无意间看到有个 golang 版的 tail -f 实现 https://github.com/hpcloud/tail
    licoycn
        2
    licoycn  
    OP
       Dec 12, 2021
    @fighterhit #1 这个我用过,是通过 fsnotify 来实现的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5910 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 02:28 · PVG 10:28 · LAX 19:28 · JFK 22:28
    ♥ Do have faith in what you're doing.