文档详情

logrotate 运行机制分析logrotate 运行机制分析.pdf

发布:2017-12-17约8.55千字共10页下载文档
文本预览下载声明
logrotate 运行机制分析: 首先系统中的自动定时运行,由 /etc/crontab 指定 [root@fullcent ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly [root@fullcent ~]# 顾名思义,每日的自动定时运行由 /etc/cron.daily 来指定 [root@fullcent ~]# cd /etc/cron.daily [root@fullcent cron.daily]# ls 0anacron cups makewhatis.cron prelink tetex.cron 0logwatch logrotate mlocate.cron rpm tmpwatch [root@fullcent cron.daily]# 在 /etc/cron.daily 中,有一个单独的 logrotate文件,这表明是和日志文件 rotate有关: [root@fullcent cron.daily]# cat logrotate #!/bin/sh /usr/sbin/logrotate /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate ALERT exited abnormally with [$EXITVALUE] fi exit 0 [root@fullcent cron.daily]# cat /etc/cron.daily/logrotate #!/bin/sh /usr/sbin/logrotate /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate ALERT exited abnormally with [$EXITVALUE] fi exit 0exit 0 [root@fullcent cron.daily]# logrotate文件中有一句话: /usr/sbin/logrotate /etc/logrotate.conf 就是说 通过 /etc/crontab.daily ,每日 logrotate 都要运行,运行参考 /etc/logrotate.conf 文件。 [root@fullcent cron.daily]# 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 # 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 -- well rotate them here /var/log/wtmp {/var/log/wtmp { mont
显示全部
相似文档