乱读天书, 不求甚解
周祎骏的个人云笔记
Toggle navigation
乱读天书, 不求甚解
主页
Linux:系统配置
Linux:用户管理
Linux:优化排错
Linux:进程调度
Linux:文件系统
Linux:网络
Linux:系统服务
Linux:安全
Linux:内核
容器:Docker
容器:containerd
容器编排:Kubernetes
IAC:Terraform
大数据:Hadoop
大数据:Zookeeper
大数据:Hbase
消息队列:rsyslog
消息队列:kafka
数据库:MySQL
数据库:MongoDB
搜索引擎:Elasticsearch
时序数据库:OpenTSDB
网站服务:Nginx
编程:Bash
编程:Perl
编程:Python
编程:C
编程:JAVA
编程:Rust
版本控制:gitlab
知识管理:docusaurus
常用小工具
关于我
标签
Redhat 1.01 logrotate
2017-03-05 14:33:05
80
0
0
admin
> 这里介绍基于crond 的日志清理机制 #大致介绍 logrotate 是一个根据配置文件的定义,把满足条件的log rotate 的程序。 它本身的调用是依赖于crond的 ``` [root@hadoop1 ~]# cat /etc/cron.daily/logrotate #!/bin/sh /usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1 EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" fi exit 0 ``` *** #使用方式 logrotate [-dv] [-f|--force] [-s|--state file] config_file .. -v 显示出都做了什么 -d debug 模式,不真的操作 -f 即使没有满足条件,也实施rotate -s 状态文件 系统默认使用的配置文件 **man 5 logrotate.conf 看细节** ``` [root@hadoop1 ~]# cat /etc/logrotate.conf # see "man logrotate" for details # rotate log files weekly weekly # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create # use date as a suffix of the rotated file dateext # uncomment this if you want your log files compressed #compress # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp and btmp -- we'll rotate them here /var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 1 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 } [root@hadoop1 ~]# cat /etc/logrotate.d/syslog /var/log/cron /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler { sharedscripts postrotate #在实施rotate之前跑的命令 /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true endscript #在实施rotate之后跑的命令 } ``` **prerotate:** rotate 之前跑的命令 **postrotate:** rotate 之后跑的命令
上一篇:
Redhat 0.02 用户环境配置
下一篇:
Redhat 3.00 RPM软件管理系统
文档导航