<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Logrotate on Coding</title>
		<link>http://coding.dong.asia/tags/logrotate/</link>
		<description>Recent content in Logrotate on Coding</description>
		<generator>Hugo</generator>
		<language>cn</language>
		
		
		
			<copyright>京ICP备17034023号 © 2019 隨風揚</copyright>
		
		
			<lastBuildDate>Wed, 14 Mar 2018 06:02:59 +0000</lastBuildDate>
		
			<atom:link href="http://coding.dong.asia/tags/logrotate/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>日志文件总管logrotate</title>
				<link>http://coding.dong.asia/linux/logrotate/</link>
				<pubDate>Wed, 14 Mar 2018 06:02:59 +0000</pubDate>
				<guid>http://coding.dong.asia/linux/logrotate/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://linuxconfig.org/logrotate&#34;&gt;logrotate官网&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;简介&#34;&gt;简介&lt;/h2&gt;&#xA;&lt;p&gt;logrotate是个十分有用的工具，它可以自动对日志进行截断、轮循、压缩以及删除旧的日志文件。配置完后，logrotate的运作完全自动化，不必进行任何人为干预。&#xA;配置文件通常在/etc/logrotate.conf中，独立配置通常在/etc/logrotate.d/下。&lt;/p&gt;&#xA;&lt;h2 id=&#34;配置&#34;&gt;配置&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;/var/log/mysql.log /var/log/mysql/*log {&#xD;&#xA;        daily&#xD;&#xA;        rotate 7&#xD;&#xA;        missingok&#xD;&#xA;        create 640 mysql adm&#xD;&#xA;        compress&#xD;&#xA;        sharedscripts&#xD;&#xA;        postrotate&#xD;&#xA;                test -x /usr/bin/mysqladmin || exit 0&#xD;&#xA;                MYADMIN=&amp;#34;/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf&amp;#34;&#xD;&#xA;                if [ -z &amp;#34;`$MYADMIN ping 2&amp;amp;gt;/dev/null`&amp;#34; ]; then&#xD;&#xA;                  if killall -q -s0 -umysql mysqld; then&#xD;&#xA;                    exit 1&#xD;&#xA;                  fi &#xD;&#xA;                else&#xD;&#xA;                  $MYADMIN flush-logs&#xD;&#xA;                fi&#xD;&#xA;        endscript&#xD;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;手动运行&#34;&gt;手动运行&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;logroute -f /et/logrotate.conf&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;定时任务&#34;&gt;定时任务&lt;/h2&gt;&#xA;&lt;p&gt;logrotate需要的cron任务应该在安装时就自动创建了：/etc/cron.daily/logrotate&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
