LOGROTATE(8) LOGROTATE(8) (NAME) logrotate - (SYNOPSIS) logrotate [--force] [--debug] [--state file] [--skip-state-lock] [--wait-for-state-lock] [--verbose] [--log file] [--mail command] config_file [config_file2 ...] (DESCRIPTION) logrotate . . . logrotate cron . logrotate -f --force . . logrotate . (include ). include . . logrotate (copyright) . logrotate . (OPTIONS) -f, --force logrotate . logrotate . -d, --debug logrotate . . -s, --state statefile logrotate . logrotate . logrotate logrotate . /var/lib/logrotate.status . /dev/null logrotate . --skip-state-lock . --wait-for-state-lock logrotate . logrotate . . -v, --verbose . -l, --log file logrotate file . logrotate -v . logrotate . -m, --mail command logrotate . : ) '-s subject' ) . . /usr/bin/mail . --usage . -?, --help . --version . (CONFIGURATION FILE) logrotate . ( ) . include . : # 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 . recipient@example.org . sharedscripts postrotate . ( ). ' " \ . /var/log/news . . . glob . GNU glob . . * logrotate . olddir ( *.log) . systemd(1) ProtectSystem=full logrotate.service . /etc /usr logrotate . logrotate : (CONFIGURATION FILE DIRECTIVES) logrotate : (Rotation) rotate count mail count . count . count -1 maxage ( ). . olddir directory directory . directory copy copytruncate renamecopy . directory . directory . noolddir . noolddir ( olddir ). su user group / ( root). user group ( ). / create . logrotate su . (Frequency) hourly . logrotate cron ( logrotate.timer systemd(1)) . logrotate . daily . weekly [weekday] weekday ( ) . weekday : ... . weekday . monthly logrotate ( ). yearly . size size size . size k . M G . size 100 size 100k size 100M size 100G . ( ). (File selection) 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 ). + . . (Files and Folders) create mode owner group, create owner group ( postrotate) ( ) . mode ( chmod(2)) owner group ( ). . nocreate . nocreate ( create ). createolddir mode [owner [group]], createolddir [owner [group]] olddir . mode olddir ( chmod(2)) owner olddir group olddir ( ). mode 0755 . nocreateolddir . nocreateolddir olddir logrotate . copy . (snapshot) . 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 (hard link) . shred copytruncate. (root) . noallowhardlink . allowhardlink . (Compression) compress gzip(1) . nocompress . nocompress . compress . compresscmd . gzip(1) . compress . uncompresscmd . gunzip(1) . compressext . . compressoptions . gzip(1) "-6" ( ). compressoptions . delaycompress . compress . . nodelaycompress ( delaycompress ). (Filenames) extension ext ext . ( .gz) ext . mylog.foo mylog.foo.1.gz mylog.1.foo.gz . addextension ext ext . ext filename filenameext filename.1ext . ( .gz) ext . start count . .0 . .9 . 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 (hourly) -%Y%m%d%H . dateformat . %s . ( // // // ). rotate logrotate . dateyesterday dateext . datehourago dateext . hourly . (Mail) mail address address . nomail . nomail . mailfirst mail . maillast mail ( ). (Additional config files) include file_or_directory include . . ( ) tabooext taboopat . ~/ . . (Scripts) sharedscripts prerotate postrotate . ( /var/log/news/*) . sharedscripts . . ( ) . nosharedscripts . nosharedscripts prerotate postrotate ( sharedscripts ). . postrotate . . firstaction script endscript script prerotate . . . . lastaction . lastaction script endscript script postrotate . . . ( ). firstaction . prerotate script endscript script . . . sharedscripts . postrotate . sharedscripts nosharedscripts . postrotate script endscript script . . . sharedscripts . prerotate . sharedscripts nosharedscripts . preremove script endscript script . logrotate . firstaction . (SCRIPTS) ( prerotate) endscript ( ) /bin/sh . logrotate stderr stdout (environment) (umask). su . --log . . (USER AND GROUP) . (FILES) /var/lib/logrotate.status . /etc/logrotate.conf . (SEE ALSO) chmod(2), gunzip(1), gzip(1), mail(1), shred(1), strftime(3), strtoul(3), (AUTHORS) Erik Troan, Preston Brown, Jan Kaluza. Linux 3.22.0 LOGROTATE(8)