Giter VIP home page Giter VIP logo

log-archive's Introduction

日志归档脚本

TOC

功能说明

以 Nginx GET 日志为例,Nginx 在 logs 目录下产生 access.log ,一段时间后,access.log 会发生轮转,此时目录下会存在 access.logaccess.log.1 ,在过一段时间,日志继续轮转,产生 access.log.2.gz...... 此时日志文件结构如下:

logs
├── access.log
├── access.log.1
├── access.log.2.gz
├── access.log.3.gz
├── access.log.4.gz
└── ...

为了方便日志分析,本脚本可以将以上日志按日期分割为 afdoa_access_log.YYYY-MM-DD.log 的日志文件存档

使用说明

./logarchive.sh <LOG_TO_ARCHIVE_PATH> <COMMON_PREFIX> <ARCHIVED_LOG_PATH> <PREFIX>

上面的命令要传递四个参数

  • LOG_TO_ARCHIVE_PATH: 待归档的日志的路径
  • COMMON_PREFIX: 待归档的日志的公共前缀
  • ARCHIVED_LOG_PATH: 归档日志的存放路径
  • PREFIX: 归档日志的文件名前缀

用法示例:

./logarchive.sh /source/logs access /destination/logs afdoa_access_log

注意事项

  • <LOG_TO_ARCHIVE_PATH> 目录下不能存在与待归档日志有相同的 <COMMON_PREFIX> 的其他文件
  • 命令执行者对 <ARCHIVED_LOG_PATH> 要有 write 权限

License

Released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.