V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
licoycn
V2EX  ›  分享创造

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

  •  2
     
  •   licoycn ·
    Licoy · 2021-12-02 13:28:17 +08:00 · 972 次点击
    这是一个创建于 898 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    tail -100f system.log
    

    windows 下就是

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

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

    fighterhit
        1
    fighterhit  
       2021-12-12 02:28:25 +08:00
    无意间看到有个 golang 版的 tail -f 实现 https://github.com/hpcloud/tail
    licoycn
        2
    licoycn  
    OP
       2021-12-12 09:40:13 +08:00
    @fighterhit #1 这个我用过,是通过 fsnotify 来实现的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2535 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:53 · PVG 15:53 · LAX 00:53 · JFK 03:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.