shiji
V2EX  ›  问与答

如何把每条新出现的 log 当作参数输入给程序处理

  •  
  •   shiji · Mar 4, 2016 · 1730 views
    This topic created in 3898 days ago, the information mentioned may be changed or developed.
    Linux 系统里面的 log 都是直接往文本里面写的。

    我需要的是,希望能实时的把新出现的每行作为一个参数输入到我的某个脚本里进行实时分析。

    问问看看大家有没有什么方法
    3 replies  •  2016-03-04 14:12:28 +08:00
    ETiV
    ETiV
    Mar 4, 2016 via iPhone
    1
    tailf path/to/your/log | your_program
    iamleung
    iamleung
    Mar 4, 2016
    2
    ./your_program | xargs tailf -n 1 path/to/your/log
    publicAdmin
    publicAdmin
    Mar 4, 2016
    3
    阿么,你为何不换个角度让你的脚本实时的去读日志文件。。看新追加的信息,
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1286 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 76ms · UTC 20:26 · PVG 04:26 · LAX 12:26 · JFK 15:26
    ♥ Do have faith in what you're doing.