<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>logrotate Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/logrotate/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Fri, 22 Nov 2019 13:11:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.13</generator>
	<item>
		<title>How to Install and Configure logrotate on Linux</title>
		<link>https://www.osradar.com/how-to-install-and-configure-logrotate-on-linux/</link>
					<comments>https://www.osradar.com/how-to-install-and-configure-logrotate-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Nabeel]]></dc:creator>
		<pubDate>Fri, 22 Nov 2019 13:11:17 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[logrotate]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=15811</guid>

					<description><![CDATA[<p>Logrotate utility is designed to used in system administration in which dated log files are archived. Servers which run large applications such as LAMP stacks, often log every activity and request in the face of bulky logs which may use high disk space on the server. Log rotation provides a way to limit the total [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-and-configure-logrotate-on-linux/">How to Install and Configure logrotate on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Logrotate utility is designed to used in system administration in which dated log files are archived. Servers which run large applications such as LAMP stacks, often log every activity and request in the face of bulky logs which may use high disk space on the server. Log rotation provides a way to limit the total size of the logs retained while still allowing analysis of recent events.</p>



<p>The primary configuration file for logrotate is /etc/logrotate.conf and it has the default settings. So, if you want additional application-specific configuration then you have to create a separate file for that application in /etc/logrotate.d directory.</p>



<p>In this article you will learn that how to configure logrotate in Linux</p>



<h2>Step 1: Install logrotate on Linux</h2>



<p>Install logrotate on Ubuntu and Debian</p>



<pre class="wp-block-preformatted">apt install logrotate </pre>



<p>Install logrotate on CentOS, RHEL and Fedora</p>



<pre class="wp-block-preformatted">yum install  -y logrotate</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="281" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/1-1-1024x281.jpg" alt="" class="wp-image-15814" srcset="https://www.osradar.com/wp-content/uploads/2019/11/1-1-1024x281.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-300x82.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-768x211.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-1536x422.jpg 1536w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-696x191.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-1068x293.jpg 1068w, https://www.osradar.com/wp-content/uploads/2019/11/1-1-1530x420.jpg 1530w, https://www.osradar.com/wp-content/uploads/2019/11/1-1.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><br>OR</p>



<pre class="wp-block-preformatted">dnf install  -y logrotate</pre>



<h2>Step 2: Configure logrotate</h2>



<p>We will configure logrotate for Apache web server in CentOS server. Let&#8217;s say we want to rotate the logs of a service &#8220;apache&#8221; that is creating logfiles under /var/log/httpd directory. So we will create a file &#8220;apache&#8221; under /etc/logrotate.d directory and make appropriate configuration in this file to rorate all the logs of apache service.</p>



<p>Run following command and add below lines in that file.</p>



<pre class="wp-block-preformatted">vi /etc/logrotate.d/apache<br></pre>



<pre class="wp-block-preformatted">/var/log/httpd/* {<br>     daily<br>     rotate 50<br>     size 2M<br>     compress<br>     delaycompress<br> }</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="226" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/2-1024x226.jpg" alt="" class="wp-image-15815" srcset="https://www.osradar.com/wp-content/uploads/2019/11/2-1024x226.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/2-300x66.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/2-768x170.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/2-696x154.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/2-1068x236.jpg 1068w, https://www.osradar.com/wp-content/uploads/2019/11/2.jpg 1271w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><br><strong>/var/log/httpd</strong> It means rotating all logs from httpd directory. <br><strong>daily</strong>  means rotate the logs on a daily basis. you can also use weekly or monthly.<br><strong>rotate 50</strong> It means last 50 rotated logs should be kept.<br><strong>size=2M</strong> means log will not be rotated until it reaches 2MB. sets the minimum size for the logs rotation. <br><strong>compress</strong> It compress the old log files to save disk space.<br><strong>delaycompress</strong> so it means rotated logs with the exception of the most recent one should be compressed.</p>



<p>now save changes to file and exit</p>



<p>You can also set many other options, for details run following command.</p>



<pre class="wp-block-preformatted">man logrotate</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="546" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/3-1024x546.jpg" alt="" class="wp-image-15816" srcset="https://www.osradar.com/wp-content/uploads/2019/11/3-1024x546.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/3-300x160.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/3-768x409.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/3-1536x818.jpg 1536w, https://www.osradar.com/wp-content/uploads/2019/11/3-696x371.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/3-1068x569.jpg 1068w, https://www.osradar.com/wp-content/uploads/2019/11/3-788x420.jpg 788w, https://www.osradar.com/wp-content/uploads/2019/11/3.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>By default, logrotate automatically configures a cron job scheduled to run daily. but we want also run our desired log rotation file, Tells logrotate to force the rotation.</p>



<pre class="wp-block-preformatted">logrotate -f /etc/logrotate.d/httpd</pre>



<p>Now run below command to see that what will logrotate do reading /etc/logrotate.d/httpd file.</p>



<pre class="wp-block-preformatted">logrotate -d /etc/logrotate.d/httpd</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1334" height="396" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2019/11/4-1024x304.jpg" alt="" class="wp-image-15817" srcset="https://www.osradar.com/wp-content/uploads/2019/11/4-1024x304.jpg 1024w, https://www.osradar.com/wp-content/uploads/2019/11/4-300x89.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/11/4-768x228.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/11/4-696x207.jpg 696w, https://www.osradar.com/wp-content/uploads/2019/11/4-1068x317.jpg 1068w, https://www.osradar.com/wp-content/uploads/2019/11/4.jpg 1334w" sizes="(max-width: 1334px) 100vw, 1334px" /></figure>



<p>That&#8217;s it, so you can use logrotate and configure it for your desired service logs like it do for Apache web server.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-install-and-configure-logrotate-on-linux/">How to Install and Configure logrotate on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-install-and-configure-logrotate-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
