LOGROTATE(8) LOGROTATE(8) logrotate - logrotate [--force] [--debug] [--state ] [--skip-state-lock] [--wait-for-state-lock] [--verbose] [--log ] [--mail ] _ [_2 ...] logrotate . . . logrotate cron . logrotate -f --force. . logrotate . . include . . logrotate . logrotate . -f --force logrotate . logrotate . -d --debug logrotate. . -s, --state _ logrotate . logrotate . logrotate logrotate 3. /var/lib/logrotate.status. /dev/null logrotate . --skip-state-lock . --wait-for-state-lock logrotate . logrotate . . -v --verbose . -l, --log logrotate _. logrotate -v. logrotate. -m --mail logrotate . : 1) '-s subject' 2) . . /usr/bin/mail. --usage . - --help . --version . logrotate . ( ) . . : # sample logrotate configuration file compress /var/log/messages { rotate 5 weekly postrotate /usr/bin/killall -HUP syslogd endscript } "/var/log/httpd/access.log" /var/log/httpd/error.log { rotate 5 mail recipient@example.org size 100k sharedscripts postrotate /usr/bin/killall -HUP httpd endscript } /var/log/news/* { monthly rotate 2 olddir /var/log/news/old missingok sharedscripts postrotate kill -HUP $(cat /var/run/inn.pid) endscript nocompress } ~/log/*.log {} . #. / = . strtoul(3). /var/log/messages. . ( ) /usr/bin/killall -HUP syslogd. /var/log/httpd/access.log /var/log/httpd/error.log. 100 ( ) recipient@example.org 5 . sharedscripts postrotate . ( ). ' " \. /var/log/news. . . glob . GNU glob . . * logrotate . olddir ( *.log). systemd(1) ProtectSystem=full logrotate.service. logrotate /etc /usr. logrotate: logrotate: rotate count count mail. count 0 . count -1 maxage ( ). 0. olddir directory directory . directory copy copytruncate renamecopy. directory . directory. noolddir. noolddir ( olddir). su user group / ( root). user group ( USER AND GROUP ). / create . logrotate root su . hourly . logrotate cron ( logrotate.timer systemd(1)). logrotate . daily . weekly [weekday] weekday 7 ( ). weekday : 0 1 ... 6 7 7 . 0 weekday. logrotate ( ). . size size size . size k . M G . size 100 size 100k size 100M size 100G . ( ). missingok . nomissingok. nomissingok . . ignoreduplicates . ifempty notifempty (ifempty ). notifempty ( ifempty). minage count . maxage count . . rotate -1 . maillast mail. minsize size size (daily weekly monthly yearly). size ( ). minsize . maxsize size size (daily weekly monthly yearly). size ( ). maxsize . tabooext [+] list ( include ). + . ,v .bak .cfsaved .disabled .dpkg-bak .dpkg-del .dpkg-dist .dpkg-new .dpkg-old .dpkg-tmp .new .old .orig .rhn-cfg-tmp-* .rpmnew .rpmorig .rpmsave .swp .ucf-dist .ucf-new .ucf-old ~ taboopat [+] list glob ( include ). + . . create mode owner group create owner group ( postrotate) ( ). mode ( chmod(2)) owner group ( USER AND GROUP ). . nocreate. nocreate ( create). createolddir mode [owner [group]] createolddir [owner [group]] olddir . mode olddir ( chmod(2)) owner olddir group olddir ( USER AND GROUP ). mode 0755. nocreateolddir. nocreateolddir olddir logrotate . copy . . create . copy olddir. nocopy . ( copy). copytruncate . () . . create . copytruncate olddir. copytruncate norenamecopy. nocopytruncate ( copytruncate). renamecopy ".tmp" . postrotate . . renamecopy olddir. renamecopy nocopytruncate. norenamecopy ( renamecopy). shred shred -u unlink(). . noshred. noshred shred . shred. shredcycles count GNU shred(1) count . shred. allowhardlink . shred copytruncate. . noallowhardlink . allowhardlink. compress gzip(1) . nocompress. nocompress . compress. compresscmd . gzip(1). compress. uncompresscmd . gunzip(1). compressext . . compressoptions . gzip(1) "-6" ( ). compressoptions . delaycompress . compress. . nodelaycompress ( delaycompress). extension ext ext . ( .gz) ext. mylog.foo mylog.1.foo.gz mylog.foo.1.gz. addextension ext ext . ext filename filenameext filename.1ext. ( .gz) ext. start count . 0 .0 . 9 .9 0-8. rotate. dateext YYYYMMDD . dateformat dateyesterday. nodateext ( dateext). dateformat format_string dateext strftime(3). %Y %m %d %H %M %S %V %s %z. -%Y%m%d -%Y%m%d%H . . 9 2001 %s . ( . 2001/12/01 01/12/2001 01/11/2002 ). rotate logrotate . dateyesterday dateext . datehourago dateext . hourly. mail address address. nomail. nomail . mailfirst mail . maillast mail ( ). include __ include. . ( ) tabooext taboopat . ~/ . . sharedscripts prerotate postrotate . ( /var/log/news/*). sharedscripts . . ( ) . nosharedscripts. nosharedscripts prerotate postrotate ( sharedscripts). . postrotate. . firstaction endscript prerotate . . . . lastaction SCRIPTS. lastaction endscript postrotate . . . ( ). firstaction SCRIPTS. prerotate endscript . . . sharedscripts . postrotate SCRIPTS. sharedscripts nosharedscripts . postrotate endscript . . . sharedscripts . prerotate SCRIPTS. sharedscripts nosharedscripts . preremove endscript . logrotate . firstaction SCRIPTS. ( prerotate) endscript ( ) ( /bin/sh). logrotate stderr stdout umask. su. --log 3 . . . /var/lib/logrotate.status . /etc/logrotate.conf . chmod(2), gunzip(1), gzip(1), mail(1), shred(1), strftime(3), strtoul(3), Erik Troan, Preston Brown, Jan Kaluza. 3 . . : . 3.22.0 LOGROTATE(8)