logrotate

Is it possible to run one logrotate check manually?

断了今生、忘了曾经 提交于 2019-11-28 13:11:55
问题 Is it possible to run one iteration of logrotate manually without scheduling it on some interval? 回答1: Yes: logrotate --force $CONFIG_FILE 回答2: logrotate -d [your_config_file] invokes debug mode, giving you a verbose description of what would happen, but leaving the log files untouched. 回答3: If you want to force-run a single specific directory or daemon's log files, you can usually find the configuration in /etc/logrotate.d , and they will work standalone. Keep in mind that global

logrotate日志管家来切割日志(tomcat,nginx,httpd的日志)

核能气质少年 提交于 2019-11-28 10:40:44
tomcatslog文件,本来应该放在/etc/logrotate.d/下的。其实无所谓了 /usr/local/tomcat1/logs/catalina.out /usr/local/tomcat2/logs/catalina.out /usr/local/tomcat3/logs/catalina.out /usr/local/tomcat4/logs/catalina.out /usr/local/tomcat5/logs/catalina.out { rotate 30 daily dateext copytruncate #notifempty missingok } 这个是系统自带的httpd的日志切割: /var/log/httpd/*log { missingok notifempty sharedscripts delaycompress postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript } 同样nginx 也可以用/usr/local/nginx/sbin/nginx -s reload,但是 nginx提供了USR1消息,来重新生成日志。所以使用 kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

你真的搞懂logrotate了吗?

一世执手 提交于 2019-11-28 10:40:16
logrotate机制&原理 centos系统中默认安装logrotate,logrotate主配置文件:/etc/logrotate.conf,其中定义了系统默认的logrotate规则,当系统中安装了RPM 软件包时,使用include定义其子配置文件的位置:/etc/logrotate.d/*,include选项十分重要,一些应用把日志转储参数存放在/etc/logrotate.d ,典型的应用有:apache,nginx,cron,syslog等,这样,只要管理一个 /etc/logrotate.conf 文件就可以了。 使用时配合crontab定期执行logrotate命令,cron的主配置文件/etc/anacrontab中定义了crontab的默认执行规则,其中系统自带的每1天执行的cron计划配置文件放在/etc/cron.daily/目录下,在该目录下的logrotate文件内容如下: #!/bin/sh /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [

日志切割操作梳理(Logrotate/python/shell脚本实现)

最后都变了- 提交于 2019-11-28 10:40:03
本文转自: 运维中的日志切割操作梳理(Logrotate/python/shell脚本实现) 对于 Linux 系统安全来说,日志文件是极其重要的工具。不知为何,我发现很多运维同学的服务器上都运行着一些诸如每天切分 Nginx 日志之类的 CRON 脚本,大家似乎遗忘了 Logrotate,争相发明自己的轮子,这真是让人沮丧啊!就好比明明身边躺着现成的性感美女,大家却忙着自娱自乐,罪过!logrotate 程序是一个日志文件管理工具。用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到“转储”作用。可以节省磁盘空间。下面就对 logrotate 日志轮转操作做一梳理记录 一、配置文件介绍 Linux系统默认安装logrotate工具,它默认的配置文件在: /etc/logrotate.conf /etc/logrotate.d/ logrotate.conf 是主要的配置文件,logrotate.d 是一个目录,该目录里的所有文件都会被主动的读入 /etc/logrotate.conf 中执行。 另外,如果 /etc/logrotate.d/ 里面的文件中没有设定一些细节,则会以/etc/logrotate.conf这个文件的设定来作为默认值。 Logrotate 是基于 CRON 来运行的,其脚本是 /etc/cron.daily/logrotate

logrotate linux 系统日志管理

泪湿孤枕 提交于 2019-11-28 07:46:32
logrotate logrotate简介 logrorare一定程度上可以简化对会生成大量日志文件的系统的管理。logrotate可以实现自动轮替、删除、压缩和mail日志的功能。 执行命令 logrotate [-dv] [-f|--force] [-s|--state statefile] config_file .. 选项 # logrotate --help Usage: logrotate [OPTION...] <configfile> -d, --debug Don't do anything, just test (implies -v) 不做实际处理,仅调试 -f, --force Force file rotation 强制执行,忽视参数要求 -m, --mail=command Command to send mail (instead of `/bin/mail') 发送mail -s, --state=statefile Path of state file 查看状态文件 -v, --verbose Display messages during rotation 轮替一次,并显示轮替过程信息 --version Display version information 显示logrotate版本 Help options: -?, --help Show

09、日志轮转+rsync同步

百般思念 提交于 2019-11-26 19:38:01
-- logrotate - rotates, compresses, and mails system logs 日志轮转 rotate 日志切割 轮转 切割 备份 归档 常见的默认已经定义轮转的日志有: /var/log/messages /var/log/cron /var/log/boot.log /var/log/maillog /var/log/secure vim /etc/logrotate.conf --配置文件 # see "man logrotate" for details # rotate log files weekly weekly --默认是一个星期rotate一次 # keep 4 weeks worth of backlogs rotate 4 --默认保留4个 # use date as a suffix of the rotated file dateext --rhel6里的新参数,表示轮转后,名字后不再以.1,.2这样的结尾,而以时间来结尾,时间格式也可以由dataformat参数来设定 # create new (empty) log files after rotating old ones create --rotate后,创建一个新的代替 # uncomment this if you want your log files