{"id":7715,"date":"2026-05-07T16:04:16","date_gmt":"2026-05-07T08:04:16","guid":{"rendered":"https:\/\/www.5x44.cn\/?p=7715"},"modified":"2026-05-12T11:11:46","modified_gmt":"2026-05-12T03:11:46","slug":"%e4%bd%bf%e7%94%a8logrotate%e8%87%aa%e5%8a%a8%e5%bd%92%e6%a1%a3mysql%e6%85%a2%e6%9f%a5%e8%af%a2%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=7715","title":{"rendered":"\u4f7f\u7528logrotate\u81ea\u52a8\u5f52\u6863mysql\u6162\u67e5\u8be2\u65e5\u5fd7"},"content":{"rendered":"\n<p>\u7531\u4e8emysql\u6162\u67e5\u8be2\u65e5\u5fd7\u5f88\u5927\uff0c\u624b\u52a8\u5f52\u6863\u6548\u7387\u4f4e\u3002\u91c7\u7528logrotate\u81ea\u52a8\u5f52\u6863\uff0c\u5e76\u5b9a\u671f\u6e05\u9664\u5197\u4f59\u65e5\u5fd7\u3002<\/p>\n\n\n\n<p>\uff081\uff09\u9996\u5148\u5728\/etc\/logrotate.d\/\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u81ea\u52a8\u5f52\u6863mysql\u6162\u67e5\u8be2\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u540d\u4e3a\uff1amysql-slow<\/p>\n\n\n\n<p>\uff082\uff09\u7f16\u8f91\u8be5\u6587\u4ef6\u5199\u5165\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9700\u8981\u5f52\u6863\u7684\u6587\u4ef6\u8def\u5f84\n\/mjxt\/mysql\/log\/slow.log {\n# \u6bcf\u5929\u6267\u884c\n    daily\n# 20\u4e2a\u6587\u4ef6\u540e\u5220\u9664\u6700\u65e9\u7684\u6587\u4ef6\n    rotate 20\n# \u538b\u7f29\uff0c\u9ed8\u8ba4\u4f7f\u7528<strong>gzip<\/strong>\n    compress\n# \u5ef6\u8fdf\u538b\u7f29\uff0c\u76f4\u5230\u4e0b\u4e00\u4e2a\u8f6e\u8be2\u5f00\u59cb\uff0c\u8fd9\u662f\u4e3a\u4e86\u9632\u6b62\u7a0b\u5e8f\u4e00\u76f4\u5411\u4e4b\u524d\u7684\u6587\u4ef6\u5199\u5165\u65e5\u5fd7\uff0c\u8981\u914d\u5408compress\u4f7f\u7528\u624d\u4f1a\u751f\u6548\n    delaycompress\n# \u5982\u679c\u6ca1\u6709\u76ee\u6807\u6587\u4ef6\u7ee7\u7eed\u6267\u884c\uff0c\u4e0d\u62a5\u9519\n    missingok\n# \u5982\u679c\u65e5\u5fd7\u662f\u7a7a\u7684\uff0c\u4e0d\u8fdb\u884c\u8f6e\u8be2\n    notifempty\n# \u5728postrotate\u811a\u672c\u8fd0\u884c\u524d\u521b\u5efa\u540c\u540d\u6587\u4ef6\uff08\u540e\u8ddf\u6743\u9650\uff0c\u7528\u6237\uff0c\u7528\u6237\u7ec4\uff09\n    create 640 ods ods\n# \u65e5\u5fd7\u88ab\u8f6e\u8be2\u540e\u6267\u884c(postrotate\u548cendscript\u4e4b\u95f4\u7684\u811a\u672c)\u7684\u811a\u672c\u547d\u4ee4\uff08\u4f7f\u7528\/bin\/sh\uff09\n    postrotate\n        \/usr\/bin\/mysql -h127.0.0.1 -P3306 -uroot -pXXXXXXXXXX -e \"FLUSH SLOW LOGS;\" 2&gt; \/dev\/null || true\n    endscript\n}<\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e\u6307\u4ee4\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The first few lines set global options; in the example, logs are compressed after they are rotated. Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a #.<\/p>\n\n\n\n<p>The next section of the config files defined how to handle the log file&nbsp;<em>\/var\/log\/messages<\/em>. The log will go through five weekly rotations before being removed. After the log file has been rotated (but before the old version of the log has been compressed), the command&nbsp;<em>\/sbin\/killall -HUP syslogd<\/em>&nbsp;will be executed.<\/p>\n\n\n\n<p>The next section defines the parameters for both&nbsp;<em>\/var\/log\/httpd\/access.log<\/em>&nbsp;and&nbsp;<em>\/var\/log\/httpd\/error.log<\/em>. They are rotated whenever it grows over 100k in size, and the old logs files are mailed (uncompressed) to&nbsp;<a href=\"mailto:www@my.org\">www@my.org<\/a>&nbsp;after going through 5 rotations, rather than being removed. The&nbsp;<strong>sharedscripts<\/strong>&nbsp;means that the&nbsp;<strong>postrotate<\/strong>&nbsp;script will only be run once (after the old logs have been compressed), not once for each log which is rotated. Note that the double quotes around the first filename at the beginning of this section allows logrotate to rotate logs with spaces in the name. Normal shell quoting rules apply, with &#8216;, &#8220;, and \\ characters supported.<\/p>\n\n\n\n<p>The last section defines the parameters for all of the files in&nbsp;<em>\/var\/log\/news<\/em>. Each file is rotated on a monthly basis. This is considered a single rotation directive and if errors occur for more than one file, the log files are not compressed.<\/p>\n\n\n\n<p>Please use wildcards with caution. If you specify *,&nbsp;<strong>logrotate<\/strong>&nbsp;will rotate all files, including previously rotated ones. A way around this is to use the&nbsp;<strong>olddir<\/strong>&nbsp;directive or a more exact wildcard (such as *.log).<\/p>\n\n\n\n<p>Here is more information on the directives which may be included in a&nbsp;<strong>logrotate<\/strong>&nbsp;configuration file:<\/p>\n\n\n\n<p><strong>compress<\/strong><\/p>\n\n\n\n<p>Old versions of log files are compressed with&nbsp;<strong><a href=\"https:\/\/linux.die.net\/man\/1\/gzip\">gzip<\/a><\/strong>(1) by default. See also&nbsp;<strong>nocompress<\/strong>.<\/p>\n\n\n\n<p><strong>compresscmd<\/strong><\/p>\n\n\n\n<p>Specifies which command to use to compress log files. The default is&nbsp;<strong>gzip<\/strong>. See also&nbsp;<strong>compress<\/strong>.<\/p>\n\n\n\n<p><strong>uncompresscmd<\/strong><\/p>\n\n\n\n<p>Specifies which command to use to uncompress log files. The default is&nbsp;<strong>gunzip<\/strong>.<\/p>\n\n\n\n<p><strong>compressext<\/strong><\/p>\n\n\n\n<p>Specifies which extension to use on compressed logfiles, if compression is enabled. The default follows that of the configured compression command.<\/p>\n\n\n\n<p><strong>compressoptions<\/strong><\/p>\n\n\n\n<p>Command line options may be passed to the compression program, if one is in use. The default, for&nbsp;<strong><a href=\"https:\/\/linux.die.net\/man\/1\/gzip\">gzip<\/a><\/strong>(1), is &#8220;-9&#8221; (maximum compression).<\/p>\n\n\n\n<p><strong>copy<\/strong><\/p>\n\n\n\n<p>Make a copy of the log file, but don&#8217;t change the original at all. This option can be used, for instance, to make a snapshot of the current log file, or when some other utility needs to truncate or parse the file. When this option is used, the&nbsp;<strong>create<\/strong>&nbsp;option will have no effect, as the old log file stays in place.<\/p>\n\n\n\n<p><strong>copytruncate<\/strong><\/p>\n\n\n\n<p>Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the&nbsp;<strong>create<\/strong>&nbsp;option will have no effect, as the old log file stays in place.<\/p>\n\n\n\n<p><strong>create<\/strong> <em>mode owner group<\/em><\/p>\n\n\n\n<p>Immediately after rotation (before the&nbsp;<strong>postrotate<\/strong>&nbsp;script is run) the log file is created (with the same name as the log file just rotated).&nbsp;<em>mode<\/em>&nbsp;specifies the mode for the log file in octal (the same as&nbsp;<strong><a href=\"https:\/\/linux.die.net\/man\/2\/chmod\">chmod<\/a><\/strong>(2)),&nbsp;<em>owner<\/em>&nbsp;specifies the user name who will own the log file, and&nbsp;<em>group<\/em>&nbsp;specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same values as the original log file for the omitted attributes. This option can be disabled using the&nbsp;<strong>nocreate<\/strong>&nbsp;option.<\/p>\n\n\n\n<p><strong>daily<\/strong><\/p>\n\n\n\n<p>Log files are rotated every day.<\/p>\n\n\n\n<p><strong>dateext<\/strong><\/p>\n\n\n\n<p>Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number. The extension may be configured using the&nbsp;<strong>dateformat<\/strong>&nbsp;option.<\/p>\n\n\n\n<p><strong>dateformat<\/strong><\/p>\n\n\n\n<p><em>format_string<\/em>Specify the extension for&nbsp;<strong>dateext<\/strong>&nbsp;using the notation similar to&nbsp;<strong><a href=\"https:\/\/linux.die.net\/man\/3\/strftime\">strftime<\/a><\/strong>(3) function. Only %Y %m %d and %s specifiers are allowed. The default value is -%Y%m%d. Note that also the character separating log name from the extension is part of the dateformat string. The system clock must be set past Sep 9th 2001 for %s to work correctly. Note that the datestamps generated by this format must be lexically sortable (i.e., first the year, then the month then the day. e.g., 2001\/12\/01 is ok, but 01\/12\/2001 is not, since 01\/11\/2002 would sort lower while it is later). This is because when using the&nbsp;<strong>rotate<\/strong>&nbsp;option, logrotate sorts all rotated filenames to find out which logfiles are older and should be removed.<\/p>\n\n\n\n<p><strong>delaycompress<\/strong><\/p>\n\n\n\n<p>Postpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with&nbsp;<strong>compress<\/strong>. It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time.<\/p>\n\n\n\n<p><strong>extension<\/strong><em> <\/em><em>ext<\/em><\/p>\n\n\n\n<p>Log files with&nbsp;<em>ext<\/em>&nbsp;extension can keep it after the rotation. If compression is used, the compression extension (normally&nbsp;<strong>.gz<\/strong>) appears after&nbsp;<em>ext<\/em>. For example you have a logfile named mylog.foo and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz.<\/p>\n\n\n\n<p><strong>ifempty<\/strong><\/p>\n\n\n\n<p>Rotate the log file even if it is empty, overriding the&nbsp;<strong>notifempty<\/strong>&nbsp;option (<strong>ifempty<\/strong>&nbsp;is the default).<\/p>\n\n\n\n<p><strong>include<\/strong><em> file_or_directory<\/em><\/p>\n\n\n\n<p>Reads the file given as an argument as if it was included inline where the&nbsp;<strong>include<\/strong>&nbsp;directive appears. If a directory is given, most of the files in that directory are read in alphabetic order before processing of the including file continues. The only files which are ignored are files which are not regular files (such as directories and named pipes) and files whose names end with one of the taboo extensions, as specified by the&nbsp;<strong>tabooext<\/strong>&nbsp;directive. The&nbsp;<strong>include<\/strong>&nbsp;directive may not appear inside a log file definition.<\/p>\n\n\n\n<p><strong>mail<\/strong><em> <\/em><em>address<\/em><\/p>\n\n\n\n<p>When a log is rotated out-of-existence, it is mailed to&nbsp;<em>address<\/em>. If no mail should be generated by a particular log, the&nbsp;<strong>nomail<\/strong>&nbsp;directive may be used.<\/p>\n\n\n\n<p><strong>mailfirst<\/strong><\/p>\n\n\n\n<p>When using the&nbsp;<strong>mail<\/strong>&nbsp;command, mail the just-rotated file, instead of the about-to-expire file.<\/p>\n\n\n\n<p><strong>maillast<\/strong><\/p>\n\n\n\n<p>When using the&nbsp;<strong>mail<\/strong>&nbsp;command, mail the about-to-expire file, instead of the just-rotated file (this is the default).<\/p>\n\n\n\n<p><strong>maxage<\/strong><em> count<\/em><\/p>\n\n\n\n<p>Remove rotated logs older than &lt;count&gt; days. The age is only checked if the logfile is to be rotated. The files are mailed to the configured address if&nbsp;<strong>maillast<\/strong>&nbsp;and&nbsp;<strong>mail<\/strong>&nbsp;are configured.<\/p>\n\n\n\n<p><strong>minsize<\/strong><em> <\/em><em>size<\/em><\/p>\n\n\n\n<p>Log files are rotated when they grow bigger than&nbsp;<em>size<\/em>&nbsp;bytes, but not before the additionally specified time interval (<strong>daily<\/strong>,&nbsp;<strong>weekly<\/strong>,&nbsp;<strong>monthly<\/strong>, or&nbsp;<strong>yearly<\/strong>). The related&nbsp;<strong>size<\/strong>&nbsp;option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When&nbsp;<strong>minsize<\/strong>&nbsp;is used, both the size and timestamp of a log file are considered.<\/p>\n\n\n\n<p><strong>missingok<\/strong><\/p>\n\n\n\n<p>If the log file is missing, go on to the next one without issuing an error message. See also&nbsp;<strong>nomissingok<\/strong>.<\/p>\n\n\n\n<p><strong>monthly<\/strong><\/p>\n\n\n\n<p>Log files are rotated the first time&nbsp;<strong>logrotate<\/strong>&nbsp;is run in a month (this is normally on the first day of the month).<\/p>\n\n\n\n<p><strong>nocompress<\/strong><\/p>\n\n\n\n<p>Old versions of log files are not compressed. See also&nbsp;<strong>compress<\/strong>.<\/p>\n\n\n\n<p><strong>nocopy<\/strong><\/p>\n\n\n\n<p>Do not copy the original log file and leave it in place. (this overrides the&nbsp;<strong>copy<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nocopytruncate<\/strong><\/p>\n\n\n\n<p>Do not truncate the original log file in place after creating a copy (this overrides the&nbsp;<strong>copytruncate<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nocreate<\/strong><\/p>\n\n\n\n<p>New log files are not created (this overrides the&nbsp;<strong>create<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nodelaycompress<\/strong><\/p>\n\n\n\n<p>Do not postpone compression of the previous log file to the next rotation cycle (this overrides the&nbsp;<strong>delaycompress<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nodateext<\/strong><\/p>\n\n\n\n<p>Do not archive old versions of log files with date extension (this overrides the&nbsp;<strong>dateext<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nomail<\/strong><\/p>\n\n\n\n<p>Don&#8217;t mail old log files to any address.<\/p>\n\n\n\n<p><strong>nomissingok<\/strong><\/p>\n\n\n\n<p>If a log file does not exist, issue an error. This is the default.<\/p>\n\n\n\n<p><strong>noolddir<\/strong>Logs are rotated in the same directory the log normally resides in (this overrides the&nbsp;<strong>olddir<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>nosharedscripts<\/strong><\/p>\n\n\n\n<p>Run&nbsp;<strong>prerotate<\/strong>&nbsp;and&nbsp;<strong>postrotate<\/strong>&nbsp;scripts for every log file which is rotated (this is the default, and overrides the&nbsp;<strong>sharedscripts<\/strong>&nbsp;option). The absolute path to the log file is passed as first argument to the script. If the scripts exit with error, the remaining actions will not be executed for the affected log only.<\/p>\n\n\n\n<p><strong>noshred<\/strong><\/p>\n\n\n\n<p>Do not use&nbsp;<strong>shred<\/strong>&nbsp;when deleting old log files. See also&nbsp;<strong>shred<\/strong>.<\/p>\n\n\n\n<p><strong>notifempty<\/strong><\/p>\n\n\n\n<p>Do not rotate the log if it is empty (this overrides the&nbsp;<strong>ifempty<\/strong>&nbsp;option).<\/p>\n\n\n\n<p><strong>olddir<\/strong><em> directory<\/em><\/p>\n\n\n\n<p>Logs are moved into&nbsp;<em>directory<\/em>&nbsp;for rotation. The&nbsp;<em>directory<\/em>&nbsp;must be on the same physical device as the log file being rotated, and is assumed to be relative to the directory holding the log file unless an absolute path name is specified. When this option is used all old versions of the log end up in&nbsp;<em>directory<\/em>. This option may be overridden by the&nbsp;<strong>noolddir<\/strong>&nbsp;option.<\/p>\n\n\n\n<p><strong>postrotate<\/strong>\/<strong>endscript<\/strong><\/p>\n\n\n\n<p>The lines between&nbsp;<strong>postrotate<\/strong>&nbsp;and&nbsp;<strong>endscript<\/strong>&nbsp;(both of which must appear on lines by themselves) are executed (using&nbsp;<strong>\/bin\/sh<\/strong>) after the log file is rotated. These directives may only appear inside a log file definition. Normally, the absolute path to the log file is passed as first argument to the script. If&nbsp;<strong>sharedscripts<\/strong>&nbsp;is specified, whole pattern is passed to the script. See also&nbsp;<strong>prerotate<\/strong>. See&nbsp;<strong>sharedscripts<\/strong>&nbsp;and&nbsp;<strong>nosharedscripts<\/strong>&nbsp;for error handling.<\/p>\n\n\n\n<p><strong>prerotate<\/strong>\/<strong>endscript<\/strong><\/p>\n\n\n\n<p>The lines between&nbsp;<strong>prerotate<\/strong>&nbsp;and&nbsp;<strong>endscript<\/strong>&nbsp;(both of which must appear on lines by themselves) are executed (using&nbsp;<strong>\/bin\/sh<\/strong>) before the log file is rotated and only if the log will actually be rotated. These directives may only appear inside a log file definition. Normally, the absolute path to the log file is passed as first argument to the script. If&nbsp;<strong>sharedscripts<\/strong>&nbsp;is specified, whole pattern is passed to the script. See also&nbsp;<strong>postrotate<\/strong>. See&nbsp;<strong>sharedscripts<\/strong>&nbsp;and&nbsp;<strong>nosharedscripts<\/strong>&nbsp;for error handling.<\/p>\n\n\n\n<p><strong>firstaction<\/strong>\/<strong>endscript<\/strong><\/p>\n\n\n\n<p>The lines between&nbsp;<strong>firstaction<\/strong>&nbsp;and&nbsp;<strong>endscript<\/strong>&nbsp;(both of which must appear on lines by themselves) are executed (using&nbsp;<strong>\/bin\/sh<\/strong>) once before all log files that match the wildcarded pattern are rotated, before prerotate script is run and only if at least one log will actually be rotated. These directives may only appear inside a log file definition. Whole pattern is passed to the script as first argument. If the script exits with error, no further processing is done. See also&nbsp;<strong>lastaction<\/strong>.<\/p>\n\n\n\n<p><strong>lastaction<\/strong>\/<strong>endscript<\/strong><\/p>\n\n\n\n<p>The lines between&nbsp;<strong>lastaction<\/strong>&nbsp;and&nbsp;<strong>endscript<\/strong>&nbsp;(both of which must appear on lines by themselves) are executed (using&nbsp;<strong>\/bin\/sh<\/strong>) once after all log files that match the wildcarded pattern are rotated, after postrotate script is run and only if at least one log is rotated. These directives may only appear inside a log file definition. Whole pattern is passed to the script as first argument. If the script exits with error, just an error message is shown (as this is the last action). See also&nbsp;<strong>firstaction<\/strong>.<\/p>\n\n\n\n<p><strong>rotate<\/strong><em> count<\/em><\/p>\n\n\n\n<p>Log files are rotated&nbsp;<em>count<\/em>&nbsp;times before being removed or mailed to the address specified in a&nbsp;<strong>mail<\/strong>&nbsp;directive. If&nbsp;<em>count<\/em>&nbsp;is 0, old versions are removed rather than rotated.<\/p>\n\n\n\n<p><strong>size<\/strong><em> <\/em><em>size<\/em><\/p>\n\n\n\n<p>Log files are rotated only if they grow bigger then&nbsp;<em>size<\/em>&nbsp;bytes. If&nbsp;<em>size<\/em>&nbsp;is followed by&nbsp;<em>k<\/em>, the size is assumed to be in kilobytes. If the&nbsp;<em>M<\/em>&nbsp;is used, the size is in megabytes, and if&nbsp;<em>G<\/em>&nbsp;is used, the size is in gigabytes. So&nbsp;<strong>size 100<\/strong>,&nbsp;<em>size 100k<\/em>,&nbsp;<em>size 100M<\/em>&nbsp;and&nbsp;<em>size 100Gare all valid.<\/em><\/p>\n\n\n\n<p><strong>sharedscripts<\/strong><\/p>\n\n\n\n<p>Normally,&nbsp;<strong>prerotate<\/strong>&nbsp;and&nbsp;<strong>postrotate<\/strong>&nbsp;scripts are run for each log which is rotated and the absolute path to the log file is passed as first argument to the script. That means a single script may be run multiple times for log file entries which match multiple files (such as the&nbsp;<em>\/var\/log\/news\/*<\/em>&nbsp;example). If&nbsp;<strong>sharedscripts<\/strong>&nbsp;is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern, and whole pattern is passed to them. However, if none of the logs in the pattern require rotating, the scripts will not be run at all. If the scripts exit with error, the remaining actions will not be executed for any logs. This option overrides the&nbsp;<strong>nosharedscripts<\/strong>&nbsp;option and implies&nbsp;<strong>create<\/strong>&nbsp;option.<\/p>\n\n\n\n<p><strong>shred<\/strong><\/p>\n\n\n\n<p>Delete log files using&nbsp;<strong>shred<\/strong>&nbsp;-u instead of unlink(). This should ensure that logs are not readable after their scheduled deletion; this is off by default. See also&nbsp;<strong>noshred<\/strong>.<\/p>\n\n\n\n<p><strong>shredcycles<\/strong><em> count<\/em><\/p>\n\n\n\n<p>Asks GNU&nbsp;<strong><a href=\"https:\/\/linux.die.net\/man\/1\/shred\">shred<\/a><\/strong>(1) to overwite log files&nbsp;<strong>count<\/strong>&nbsp;times before deletion. Without this option,&nbsp;<strong>shred<\/strong>&#8216;s default will be used.<\/p>\n\n\n\n<p><strong>start<\/strong><em> count<\/em><\/p>\n\n\n\n<p>This is the number to use as the base for rotation. For example, if you specify 0, the logs will be created with a .0 extension as they are rotated from the original log files. If you specify 9, log files will be created with a .9, skipping 0-8. Files will still be rotated the number of times specified with the&nbsp;<strong>count<\/strong>&nbsp;directive.<\/p>\n\n\n\n<p><strong>tabooext<\/strong>&nbsp;[+]&nbsp;<em>list<\/em><\/p>\n\n\n\n<p>The current taboo extension list is changed (see the&nbsp;<strong>include<\/strong>&nbsp;directive for information on the taboo extensions). If a + precedes the list of extensions, the current taboo extension list is augmented, otherwise it is replaced. At startup, the taboo extension list contains .rpmorig, .rpmsave, ,v, .swp, .rpmnew, ~, .cfsaved and .rhn-cfg-tmp-*.<\/p>\n\n\n\n<p><strong>weekly<\/strong><\/p>\n\n\n\n<p>Log files are rotated if the current weekday is less than the weekday of the last rotation or if more than a week has passed since the last rotation. This is normally the same as rotating logs on the first day of the week, but it works better if&nbsp;<em>logrotate<\/em>&nbsp;is not run every night.<\/p>\n\n\n\n<p><strong>yearly<\/strong><\/p>\n\n\n\n<p>Log files are rotated if the current year is not the same as the last rotation.<\/p>\n<\/blockquote>\n<\/blockquote>\n\n\n\n<p>\u914d\u7f6e\u624b\u518c\uff1a <a href=\"https:\/\/linux.die.net\/man\/8\/logrotate\">https:\/\/linux.die.net\/man\/8\/logrotate<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ:<\/h2>\n\n\n\n<p>(1)\u4e0d\u6267\u884c\u914d\u7f6e\uff1a\u68c0\u67e5crond\u670d\u52a1\u662f\u5426\u5728\u8fd0\u884c\uff0c\/etc\/cron.daily\/logrotate \u662f\u5426\u5177\u6709\u6267\u884c\u6743\u9650(\u6b63\u5e38\u5e94\u8be5\u662f0700\uff0c\u6839\u636e\u6267\u884c\u5468\u671f\u68c0\u67e5\u5bf9\u5e94\u7684cron.XXXX\u76ee\u5f55)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8emysql\u6162\u67e5\u8be2\u65e5\u5fd7\u5f88\u5927\uff0c\u624b\u52a8\u5f52\u6863\u6548\u7387\u4f4e\u3002\u91c7\u7528logrotate\u81ea\u52a8\u5f52\u6863\uff0c\u5e76\u5b9a\u671f\u6e05\u9664\u5197\u4f59\u65e5\u5fd7\u3002 \uff081\uff09\u9996\u5148\u5728\/etc\/logrotate.d\/\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=7715\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,37],"tags":[],"class_list":["post-7715","post","type-post","status-publish","format-standard","hentry","category-it","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/7715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7715"}],"version-history":[{"count":5,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/7715\/revisions"}],"predecessor-version":[{"id":7727,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/7715\/revisions\/7727"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}