{"id":682,"date":"2015-03-16T21:12:29","date_gmt":"2015-03-16T21:12:29","guid":{"rendered":"http:\/\/www.balajibandi.com\/?p=682"},"modified":"2018-07-16T21:21:00","modified_gmt":"2018-07-16T20:21:00","slug":"how-to-logrotate-in-linux","status":"publish","type":"post","link":"https:\/\/www.balajibandi.com\/?p=682","title":{"rendered":"How To Logrotate in Linux"},"content":{"rendered":"<p>Logrotate is a handy tool for system administrators who wish to take the \/var\/log directory under their control. The logrotate command is called daily by the cron scheduler and it reads the following files:<\/p>\n<ul>\n<li>the logrotate configuration file \/etc\/logrotate.conf<\/li>\n<li>files in the logrotate configuration directory \/etc\/logrotate.d Most of the services (Apache webserver, postgreSQL, MySql, KDE desktop manager etc.) installed on your system create a configuration file for logrotate in \/etc\/logrotate.d. For example here are the contents of my \/etc\/logrotate.d directory:<\/li>\n<\/ul>\n<p>#pwd<\/p>\n<p id=\"FxQgEYl\"><img loading=\"lazy\" decoding=\"async\" width=\"255\" height=\"35\" class=\"alignnone size-full wp-image-684 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfc65d321a.png\" alt=\"\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>#ls -al<\/p>\n<p id=\"jYWGprV\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"33\" class=\"alignnone size-full wp-image-685 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfc8fa72ca.png\" alt=\"\" srcset=\"https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfc8fa72ca.png 1000w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfc8fa72ca-300x10.png 300w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfc8fa72ca-768x25.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p>I have created a File calles raw, which rotate my raw syslog messages<\/p>\n<p id=\"lqpFulr\"><img loading=\"lazy\" decoding=\"async\" width=\"310\" height=\"152\" class=\"alignnone size-full wp-image-686 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfcbb32fb2.png\" alt=\"\" srcset=\"https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfcbb32fb2.png 310w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfcbb32fb2-300x147.png 300w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/p>\n<p>My raw log stored under \/var\/syslog-ng\/raw\/alldevices.log<\/p>\n<p>Rotate 20 &#8211; keep 20 archives<\/p>\n<p>create 0644 root root &#8211; create new file with 644 permittion as owner root<\/p>\n<p>daily &#8211; run daily once<\/p>\n<p>no commress &#8211; its rotate as it is ( it will not compress, if need use compress).<\/p>\n<p>missingok &#8211;\u00a0If the log file is missing, go on to the next one without issuing an error message.<\/p>\n<p>save the file as mentioned<\/p>\n<p>cp the file in to \/etc\/logrotate.d<\/p>\n<p>change the ownership<\/p>\n<p>chmod 0644 raw<\/p>\n<p>chown root root raw<\/p>\n<p>testing<\/p>\n<p>logrotate -f \/etc\/logrotate.d\/raw you should not see any errors.<\/p>\n<p>go to directory and see the archive created or not.<\/p>\n<p id=\"BgLcdoc\"><img loading=\"lazy\" decoding=\"async\" width=\"426\" height=\"38\" class=\"alignnone size-full wp-image-687 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfdf15d2a4.png\" alt=\"\" srcset=\"https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfdf15d2a4.png 426w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2018\/07\/img_5b4cfdf15d2a4-300x27.png 300w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/p>\n<p>Note : above you can see compress also i have tested compress also.<\/p>\n<p>hope you enjoyed, Happy Labbiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Logrotate is a handy tool for system administrators who wish to take the \/var\/log directory under their control. The logrotate command is called daily by the cron scheduler and it reads the following files: the logrotate configuration file \/etc\/logrotate.conf files in the logrotate configuration directory \/etc\/logrotate.d Most of the services (Apache webserver, postgreSQL, MySql, KDE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1],"tags":[],"class_list":["post-682","post","type-post","status-publish","format-standard","hentry","category-linux","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=682"}],"version-history":[{"count":2,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/682\/revisions"}],"predecessor-version":[{"id":688,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/682\/revisions\/688"}],"wp:attachment":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}