duanmaduan1848 2011-12-13 00:59
浏览 30
已采纳

打开/处理580GB错误日志文件的建议

A friend asked me to help him with a simple php script I placed on their Wordpress site. In doing so, I came across a few glaring issues I thought I could help him with. Then I came across the beast.

A 580 gigabyte error log file.

This is a simple blog, granted with millions of views a month and gigabytes of pictures, but shouldn't he do some maintenance on the thing? I know I could tail -f the log file in most circumstances but I think it may make planets collide trying to open a text file that large.

Question

Should I tell him to just wipe it and start monitoring it fresh from here on out or is there a proper way to review even, say, the last 10 days worth of logs? I haven't spent enough time on their server (just browsed FTP) to see what they are running.

  • 写回答

3条回答 默认 最新

  • douxu5845 2011-12-13 01:06
    关注

    This gives you the last 100 lines:

    tail -n 100 logfile > last-100-lines.log
    

    In terms of 'date', you could also:

    cat |grep '2012-12' > all-dec.log
    

    Not, the exact term to grep for depends on what the log file looks like. Both operations will take a little while to run. If this application is disk-intense, you could run into problems by saturating the disk since this monster is pretty large and it's very unlikely you have 600+ GB of RAM and that log file is cached in memory. ;-)

    Anyway, for kicks, try bzip2 --best logfile and then download it and then evaluate it on localhost.

    It's not pretty to work with files that large, but it should be do-able.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏