GithubHelp home page GithubHelp logo

clearlogs-shell's Introduction

clearlogs-shell

A shell,clear logs for linux

用途:
ghostsf维护服务器有几次发现服务器出现奇葩错误,检查了下发现是写入异常,然后发现磁盘满了。然后再已检查,累积的服务器log达到了上百G,这就尴尬了。所以定期清理这些日志文件是有必要的,尤其对那些空间容量小的服务器。

使用方法:
建一个.sh结尾的shell脚本文件,然后修改下相关服务器log日志文件目录,直接执行接口。
可以结合crontab,进行定期执行清理log的脚本。
当然脚本代码都在这里了,想怎么改就怎么改。

方法说明:
脚本里写了三个简单方法,当然你也可以自己修改或增加的。
delete_old_log() 用来删除指定目录,指定时间内的log日志。当然这里指定的时间,是指设定的DAYS之前的日志。具体可参考find -mtime + 的含义。
compress_log() 用于压缩备份一下日志
rotate_catalina_log() 用于清空日志以及备份日志,不要备份就直接删掉/bin/cp $TOMCAT_LOG_DIR/catalina.out
$TOMCAT_LOG_DIR/catalina.out.$HOSTNAME.$DATE即可。

clearlogs-shell's People

Contributors

ghostsf avatar

Stargazers

 avatar

Watchers

 avatar

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.