{"id":8484,"date":"2024-04-22T13:29:45","date_gmt":"2024-04-22T13:29:45","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=8484"},"modified":"2024-04-22T13:29:57","modified_gmt":"2024-04-22T13:29:57","slug":"tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/","title":{"rendered":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en.jpg\" alt=\"Log File Management with Logrotate on Ubuntu\" class=\"wp-image-8492\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>In any production server environment, managing <strong>log files<\/strong> is a crucial aspect of system administration. Log files contain valuable information about system events, application behavior, and potential issues, making them indispensable for troubleshooting and monitoring purposes. However, if left unchecked, log files can grow rapidly, consuming significant disk space and potentially leading to performance degradation or even system crashes.<\/p>\n\n\n\n<p><strong>Logrotate<\/strong> is a powerful utility designed to address this issue by automatically rotating, compressing, and pruning log files based on predefined rules and schedules. By regularly compressing and archiving old log files, and removing obsolete ones, Logrotate ensures that disk space is used efficiently and that log files remain manageable.<\/p>\n\n\n\n<p>In this comprehensive guide, we will explore Logrotate&#8217;s functionality, its default configuration on Ubuntu 20.04 and 22.04, and walk through the process of setting up custom log rotation rules for a fictional application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h2>\n\n\n\n<p>Before proceeding, ensure that you have the following:<\/p>\n\n\n\n<ul>\n<li>An Ubuntu 20.04 or 22.04 server with a non-root user account with sudo privileges.<\/li>\n\n\n\n<li>Familiarity with basic command-line operations and text editing.<\/li>\n<\/ul>\n\n\n\n<p>Logrotate is pre-installed on Ubuntu, but if you need to install it manually, you can do so by running the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt update\n$ sudo apt install logrotate<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-verifying-the-logrotate-version\">Step 1: Verifying the Logrotate Version<\/h2>\n\n\n\n<p>Although Logrotate comes pre-installed on Ubuntu, it&#8217;s a good practice to verify the installed version and its default settings. You can do this by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ logrotate --version<\/code><\/pre>\n\n\n\n<p>This command will display the version number, as well as information about default settings such as the mail command, compression command, and state file path. Here&#8217;s an example output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">logrotate 3.19.0\n    Default mail command:       \/usr\/bin\/mail\n    Default compress command:   \/bin\/gzip\n    Default uncompress command: \/bin\/gunzip\n    Default compress extension: .gz\n    Default state file path:    \/var\/lib\/logrotate\/status\n    ACL support:                yes\n    SELinux support:            yes<\/code><\/pre>\n\n\n\n<p>If you&#8217;re using a non-Ubuntu distribution or have a significantly different version of Logrotate, some configuration options covered in this guide may not apply. In such cases, consult the man pages (<code>man logrotate<\/code>) or online documentation for your specific Logrotate version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-exploring-the-default-configuration\">Step 2: Exploring the Default Configuration<\/h2>\n\n\n\n<p>On Ubuntu systems, Logrotate&#8217;s configuration is primarily managed through two locations:<\/p>\n\n\n\n<ol>\n<li><code>\/etc\/logrotate.conf<\/code>: This file contains the default settings and sets up log rotation for a few system logs that are not owned by any installed packages. It also includes configuration files from the&nbsp;<code>\/etc\/logrotate.d<\/code>&nbsp;directory using an&nbsp;<code>include<\/code>&nbsp;statement.<\/li>\n\n\n\n<li><code>\/etc\/logrotate.d\/<\/code>: This directory contains configuration files for various installed packages that require log rotation. For example, you&#8217;ll find configuration files for core system tools like&nbsp;<code>apt<\/code>,&nbsp;<code>dpkg<\/code>,&nbsp;<code>rsyslog<\/code>, and others.<\/li>\n<\/ol>\n\n\n\n<p>Let&#8217;s examine the default configuration in the&nbsp;<code>\/etc\/logrotate.conf<\/code>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo cat \/etc\/logrotate.conf<\/code><\/pre>\n\n\n\n<p>This file sets up weekly log rotations for log files owned by the root user and the syslog group. It keeps four rotated log files (<code>rotate 4<\/code>) and creates new empty log files after rotation (<code>create<\/code>). Additionally, it includes configuration files from the&nbsp;<code>\/etc\/logrotate.d<\/code>&nbsp;directory.<\/p>\n\n\n\n<p>Next, let&#8217;s look at an example configuration file from the&nbsp;<code>\/etc\/logrotate.d<\/code>&nbsp;directory for the&nbsp;<code>apt<\/code>&nbsp;package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo cat \/etc\/logrotate.d\/apt<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">\/var\/log\/apt\/term.log {\n  rotate 12\n  monthly\n  compress\n  missingok\n  notifempty\n}\n\n\/var\/log\/apt\/history.log {\n  rotate 12\n  monthly\n  compress\n  missingok\n  notifempty\n}<\/code><\/pre>\n\n\n\n<p>This file contains configuration blocks for two log files:&nbsp;<code>term.log<\/code>&nbsp;and&nbsp;<code>history.log<\/code>, located in the&nbsp;<code>\/var\/log\/apt\/<\/code>&nbsp;directory. The configuration options used here are:<\/p>\n\n\n\n<ul>\n<li><code>rotate 12<\/code>: Keep 12 old rotated log files (overriding the default of 4).<\/li>\n\n\n\n<li><code>monthly<\/code>: Rotate the logs once a month (overriding the default of weekly).<\/li>\n\n\n\n<li><code>compress<\/code>: Compress the rotated log files using gzip.<\/li>\n\n\n\n<li><code>missingok<\/code>: Don&#8217;t generate an error if the log file is missing.<\/li>\n\n\n\n<li><code>notifempty<\/code>: Don&#8217;t rotate the log file if it&#8217;s empty.<\/li>\n<\/ul>\n\n\n\n<p>Any options not specified in these configuration blocks will inherit the default values from&nbsp;<code>\/etc\/logrotate.conf<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-setting-up-a-custom-configuration\">Step 3: Setting Up a Custom Configuration<\/h2>\n\n\n\n<p>While the default configuration is sufficient for most system logs, you may need to set up custom log rotation rules for your applications. Logrotate offers two main approaches for this:<\/p>\n\n\n\n<ol>\n<li><strong>Adding Configuration to&nbsp;<code>\/etc\/logrotate.d\/<\/code><\/strong><\/li>\n\n\n\n<li><strong>Creating an Independent Configuration<\/strong><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"adding-configuration-to-etclogrotated\">Adding Configuration to&nbsp;<code>\/etc\/logrotate.d\/<\/code><\/h3>\n\n\n\n<p>This approach involves creating a new configuration file in the&nbsp;<code>\/etc\/logrotate.d\/<\/code>&nbsp;directory. The configuration defined in this file will be run daily as the root user, along with all the other default Logrotate jobs.<\/p>\n\n\n\n<p>Let&#8217;s set up a configuration for a fictional web application called &#8220;your-app&#8221; that generates&nbsp;<code>access.log<\/code>&nbsp;and&nbsp;<code>error.log<\/code>&nbsp;files in the&nbsp;<code>\/var\/log\/your-app\/<\/code>&nbsp;directory. The application runs as the&nbsp;<code>www-data<\/code>&nbsp;user and group.<\/p>\n\n\n\n<p>First, create a new configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo nano \/etc\/logrotate.d\/your-app<\/code><\/pre>\n\n\n\n<p>Add the following configuration to the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">\/var\/log\/your-app\/*.log {\n    daily\n    missingok\n    rotate 14\n    compress\n    notifempty\n    create 0640 www-data www-data\n    sharedscripts\n    postrotate\n        systemctl reload your-app\n    endscript\n}<\/code><\/pre>\n\n\n\n<p>Here&#8217;s what each option does:<\/p>\n\n\n\n<ul>\n<li><code>daily<\/code>: Rotate the logs daily (overriding the default weekly rotation).<\/li>\n\n\n\n<li><code>missingok<\/code>: Don&#8217;t generate an error if the log file is missing.<\/li>\n\n\n\n<li><code>rotate 14<\/code>: Keep 14 old rotated log files.<\/li>\n\n\n\n<li><code>compress<\/code>: Compress the rotated log files using gzip.<\/li>\n\n\n\n<li><code>notifempty<\/code>: Don&#8217;t rotate the log file if it&#8217;s empty.<\/li>\n\n\n\n<li><code>create 0640 www-data www-data<\/code>: Create a new empty log file with permissions&nbsp;<code>0640<\/code>, owned by the&nbsp;<code>www-data<\/code>&nbsp;user and group.<\/li>\n\n\n\n<li><code>sharedscripts<\/code>: Run any scripts defined in the configuration (e.g.,&nbsp;<code>postrotate<\/code>) only once per run, instead of for each log file.<\/li>\n\n\n\n<li><code>postrotate<\/code>&nbsp;to&nbsp;<code>endscript<\/code>: This block contains a script that will run after log rotation. In this case, it reloads the&nbsp;<code>your-app<\/code>&nbsp;service to ensure it starts writing to the new log file.<\/li>\n<\/ul>\n\n\n\n<p>Save and close the file. You can test the configuration by running a dry run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo logrotate \/etc\/logrotate.conf --debug<\/code><\/pre>\n\n\n\n<p>This command executes Logrotate with the standard configuration file and enables debug mode, printing information about which log files would be handled and the actions that would be taken.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"creating-an-independent-configuration\">Creating an Independent Configuration<\/h3>\n\n\n\n<p>In some cases, you may need to run Logrotate as a non-root user or rotate logs more frequently than the default daily schedule. In such situations, you can create an independent Logrotate configuration and set up a cron job to run it at the desired interval.<\/p>\n\n\n\n<p>Suppose you have an application running as the&nbsp;<code>bob<\/code>&nbsp;user, generating logs in the&nbsp;<code>\/home\/bob\/logs\/<\/code>&nbsp;directory. You want to rotate these logs hourly.<\/p>\n\n\n\n<p>First, create a configuration file in your home directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nano \/home\/bob\/logrotate.conf<\/code><\/pre>\n\n\n\n<p>Add the following configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">\/home\/bob\/logs\/*.log {\n    hourly\n    missingok\n    rotate 24\n    compress\n    create\n}<\/code><\/pre>\n\n\n\n<p>This configuration will rotate the logs hourly, keeping 24 old rotated log files, compressing them, and creating a new empty log file after rotation.<\/p>\n\n\n\n<p>Save and close the file.<\/p>\n\n\n\n<p>Next, create a log file for testing purposes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cd ~\n$ mkdir logs\n$ touch logs\/access.log<\/code><\/pre>\n\n\n\n<p>Now, run Logrotate with the new configuration and specify a state file location:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ logrotate \/home\/bob\/logrotate.conf --state \/home\/bob\/logrotate-state --verbose<\/code><\/pre>\n\n\n\n<p>The&nbsp;<code>--state<\/code>&nbsp;option specifies the location of the state file, which records information about the logs processed during each run. The&nbsp;<code>--verbose<\/code>&nbsp;flag displays detailed output about Logrotate&#8217;s actions.<\/p>\n\n\n\n<p>You should see output similar to the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">reading config file \/home\/bob\/logrotate.conf\nHandling 1 logs\nrotating pattern: \/home\/bob\/logs\/*.log  hourly (24 rotations)\nempty log files are rotated, old logs are removed\nconsidering log \/home\/bob\/logs\/access.log\n  log does not need rotating<\/code><\/pre>\n\n\n\n<p>Logrotate recorded information about the logs it encountered in the state file. You can view the contents of the state file with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat \/home\/bob\/logrotate-state<\/code><\/pre>\n\n\n\n<p>If you run the same command an hour later, the log file should be rotated as expected.<\/p>\n\n\n\n<p>To force Logrotate to rotate the log file immediately (for testing purposes), use the&nbsp;<code>--force<\/code>&nbsp;flag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ logrotate \/home\/bob\/logrotate.conf --state \/home\/bob\/logrotate-state --verbose --force<\/code><\/pre>\n\n\n\n<p>Finally, set up a cron job to run Logrotate hourly. Open your user&#8217;s crontab with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ crontab -e<\/code><\/pre>\n\n\n\n<p>Add the following line to the crontab file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">14 * * * * \/usr\/sbin\/logrotate \/home\/bob\/logrotate.conf --state \/home\/bob\/logrotate-state<\/code><\/pre>\n\n\n\n<p>This will run the&nbsp;<code>logrotate<\/code>&nbsp;command on the 14th minute of every hour, using the full path to the&nbsp;<code>logrotate<\/code>&nbsp;binary and specifying the configuration file and state file locations.<\/p>\n\n\n\n<p>Save and exit the crontab file. The cron job will now run at the specified schedule.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advanced-configuration-options\">Advanced Configuration Options<\/h2>\n\n\n\n<p>While the examples covered in this guide demonstrate some common Logrotate options, there are many more advanced options available for fine-tuning log rotation behavior. Here are a few notable options:<\/p>\n\n\n\n<ul>\n<li><code>dateext<\/code>: This option appends a date extension to the rotated log file names, making it easier to identify the time period covered by each log file.<\/li>\n\n\n\n<li><code>dateformat<\/code>: Specifies the date format to be used with&nbsp;<code>dateext<\/code>.<\/li>\n\n\n\n<li><code>mail<\/code>: Sends a log file rotation report to the specified email address.<\/li>\n\n\n\n<li><code>olddir<\/code>: Moves rotated log files to a different directory instead of keeping them in the same directory as the current log file.<\/li>\n\n\n\n<li><code>prerotate<\/code>&nbsp;and&nbsp;<code>postrotate<\/code>: These options allow you to run scripts before and after log rotation, respectively.<\/li>\n\n\n\n<li><code>size<\/code>: Rotates log files based on their size, instead of a fixed schedule.<\/li>\n<\/ul>\n\n\n\n<p>You can explore these and other options by consulting the Logrotate manual page (<code>man logrotate<\/code>) or the online documentation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Effective log file management is crucial for maintaining a healthy server environment and ensuring that valuable log data is preserved and accessible when needed. Logrotate is a powerful tool that simplifies this task by automating log rotation, compression, and pruning based on customizable rules and schedules.<\/p>\n\n\n\n<p>By following the examples and best practices outlined in this guide, you can effectively manage log files for your applications, ensuring optimal disk space utilization and easy access to historical log data when needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In any production server environment, managing log files is a crucial aspect of system administration. Log files contain valuable information about system events, application behavior, and potential issues, making them indispensable for troubleshooting and monitoring purposes. However, if left unchecked, log files can grow rapidly, consuming significant disk space and potentially leading to performance degradation ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,3],"tags":[],"yoast_head":"\n<title>Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-22T13:29:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-22T13:29:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04\",\"datePublished\":\"2024-04-22T13:29:45+00:00\",\"dateModified\":\"2024-04-22T13:29:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\"},\"wordCount\":1359,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Linux system administration\",\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\",\"name\":\"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2024-04-22T13:29:45+00:00\",\"dateModified\":\"2024-04-22T13:29:57+00:00\",\"description\":\"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations","description":"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/","og_locale":"en_US","og_type":"article","og_title":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations","og_description":"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.","og_url":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2024-04-22T13:29:45+00:00","article_modified_time":"2024-04-22T13:29:57+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/04\/logrotate_ubuntu_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04","datePublished":"2024-04-22T13:29:45+00:00","dateModified":"2024-04-22T13:29:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/"},"wordCount":1359,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Linux system administration","Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/","url":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/","name":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04 - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2024-04-22T13:29:45+00:00","dateModified":"2024-04-22T13:29:57+00:00","description":"Comprehensive guide on managing log files with Logrotate on Ubuntu 20.04\/22.04, including exploring its features, default configuration, and setting up custom log rotation rules.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/tutorial-log-file-management-logrotate-ubuntu-18-04-20-04-22-04\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"Comprehensive guide to Log file management with Logrotate on Ubuntu 20.04\/22.04"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/8484"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=8484"}],"version-history":[{"count":4,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/8484\/revisions"}],"predecessor-version":[{"id":8498,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/8484\/revisions\/8498"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=8484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=8484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=8484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}