{"id":248,"date":"2024-05-06T06:41:57","date_gmt":"2024-05-06T06:41:57","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=248"},"modified":"2024-06-23T05:26:04","modified_gmt":"2024-06-23T05:26:04","slug":"how-to-find-remove-large-error_log-files-in-linux","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html","title":{"rendered":"How To Find &#038; Remove Large Error_log Files In Linux"},"content":{"rendered":"<header class=\"hkb-article__header\"><\/header>\n<div class=\"ht-mobile-toc\">\n<nav id=\"navtoc\" class=\"active\" role=\"navigation\">In this tutorial, you will learn how to find and remove large error_log files generated by your scripts, while running from a Linux platform.<\/nav>\n<\/div>\n<div class=\"hkb-article__content\">\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html\/#How_To_Find_Error_log_Files_In_Linux\" >How To Find Error_log Files In Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html\/#How_To_Find_And_Delete_Error_log_Files_In_Linux\" >How To Find And Delete Error_log Files In Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html\/#How_To_Find_All_The_Error_log_Files_Larger_Than_1_GB\" >How To Find All The Error_log Files Larger Than 1 GB<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html\/#How_To_Find_And_Remove_All_The_Error_log_Files_Larger_Than_1_GB\" >How To Find And Remove All The Error_log Files Larger Than 1 GB<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/zalvis.com\/docs\/how-to-find-remove-large-error_log-files-in-linux.html\/#How_To_Find_And_Delete_Error_log_Files_Using_A_Cron_Job\" >How To Find And Delete Error_log Files Using A Cron Job<\/a><\/li><\/ul><\/nav><\/div>\n<h3 id=\"how-to-find-error-log-files-in-linux\"><span class=\"ez-toc-section\" id=\"How_To_Find_Error_log_Files_In_Linux\"><\/span><span id=\"how-to-find-error_log-files-in-linux\">How To Find Error_log Files In Linux<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>List the Error Log files with its disk space usage details:<\/p>\n<pre># find . -type f -iname error_log -exec du -sh {} \\;<\/pre>\n<ul>\n<li>type : Specify the type to find.<\/li>\n<li>iname: Specify the name to find.<\/li>\n<li>exec: Execute the \u201cdu -sch\u201d and lists the output with file size.<\/li>\n<\/ul>\n<h3 id=\"how-to-find-and-delete-error-log-files-in-linux\"><span class=\"ez-toc-section\" id=\"How_To_Find_And_Delete_Error_log_Files_In_Linux\"><\/span><span id=\"how-to-find-and-delete-error_log-files-in-linux\">How To Find And Delete Error_log Files In Linux<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre># find . -type f -iname error_log -delete<\/pre>\n<ul>\n<li>delete: This switch removes the outputs from the find command.<\/li>\n<\/ul>\n<h3 id=\"how-to-find-all-the-error-log-files-larger-than-1-gb\"><span class=\"ez-toc-section\" id=\"How_To_Find_All_The_Error_log_Files_Larger_Than_1_GB\"><\/span><span id=\"how-to-find-all-the-error_log-files-larger-than-1-gb\">How To Find All The Error_log Files Larger Than 1 GB<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To find all the error_log files larger than 1 GB (1,073,741,824 bytes) in the current directory and its subdirectories, you can use the following command:<\/p>\n<pre>find . -<span class=\"hljs-built_in\">type<\/span> f -name <span class=\"hljs-string\">\"error_log\"<\/span> -size +1000000000c -<span class=\"hljs-built_in\">exec<\/span> <span class=\"hljs-built_in\">ls<\/span> -lh {} \\;<\/pre>\n<p>Explanation of the command options:<\/p>\n<ul>\n<li><code>find .<\/code>: start searching from the current directory (<code>.<\/code>)<\/li>\n<li><code>-type f<\/code>: only look for files (not directories)<\/li>\n<li><code>-name \"error_log\"<\/code>: only consider files with the name \u201cerror_log\u201d<\/li>\n<li><code>-size +1000000000c<\/code>: only consider files that are larger than 1 GB (1,000,000,000 bytes)<\/li>\n<li><code>-exec ls -lh {} \\;<\/code>: run the <code>ls -lh<\/code>command on each file found, displaying its size in human-readable format. The <code>{}<\/code>placeholder is replaced with the path to each file, and the <code>\\;<\/code> is used to end the <code>exec<\/code>command.<\/li>\n<\/ul>\n<p>The <code>ls -lh<\/code> command displays information about the files, including their size, permissions, and modification date. The <code>-h<\/code> option makes the size human-readable, so it will show values like \u201c1.0G\u201d instead of \u201c1000000000\u201d.<\/p>\n<h3 id=\"how-to-find-and-remove-all-the-error-log-files-larger-than-1-gb\"><span class=\"ez-toc-section\" id=\"How_To_Find_And_Remove_All_The_Error_log_Files_Larger_Than_1_GB\"><\/span><span id=\"how-to-find-and-remove-all-the-error_log-files-larger-than-1-gb\">How To Find And Remove All The Error_log Files Larger Than 1 GB<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre>find . -<span class=\"hljs-built_in\">type<\/span> f -name <span class=\"hljs-string\">\"error_log\"<\/span> -size +1000000000c -<span class=\"hljs-built_in\">exec<\/span> <span class=\"hljs-built_in\">rm<\/span> {} \\;<\/pre>\n<div class=\"flex-1 overflow-hidden\">\n<div class=\"react-scroll-to-bottom--css-wrrre-79elbk h-full dark:bg-gray-800\">\n<div class=\"react-scroll-to-bottom--css-wrrre-1n7m0yu\">\n<div class=\"flex flex-col items-center text-sm dark:bg-gray-800\">\n<div class=\"w-full border-b border-black\/10 dark:border-gray-900\/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]\">\n<div class=\"text-base gap-4 md:gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0\">\n<div class=\"relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]\">\n<div class=\"flex flex-grow flex-col gap-3\">\n<div class=\"min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>Explanation of the command options:<\/p>\n<ul>\n<li><code>find .<\/code>: start searching from the current directory (<code>.<\/code>)<\/li>\n<li><code>-type f<\/code>: only look for files (not directories)<\/li>\n<li><code>-name \"error_log\"<\/code>: only consider files with the name \u201cerror_log\u201d<\/li>\n<li><code>-size +1000000000c<\/code>: only consider files that are larger than 1 GB (1,000,000,000 bytes)<\/li>\n<li><code>-exec rm {} \\;<\/code>: run the <code>rm<\/code> command on each file found, removing it from the file system. The <code>{}<\/code> placeholder is replaced with the path to each file, and the <code>\\;<\/code> is used to end the <code>exec<\/code> command.<\/li>\n<\/ul>\n<p>Note: The <code>rm<\/code> command permanently deletes files. Make sure you want to delete the files before running this command, as it does not send the files to the trash bin or provide any means to recover the deleted files.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 id=\"how-to-find-and-delete-error-log-files-using-a-cron-job\"><span class=\"ez-toc-section\" id=\"How_To_Find_And_Delete_Error_log_Files_Using_A_Cron_Job\"><\/span><span id=\"how-to-find-and-delete-error_log-files-using-a-cron-job\">How To Find And Delete Error_log Files Using A Cron Job<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you want to automatically remove all the error_log files which are being generated, you can achieve this by setting up a cron job.<\/p>\n<p>The command that the cron job should execute is:<\/p>\n<pre>\/bin\/find \/home\/user -type f -iname error_log -delete<\/pre>\n<p>Example: 0 * * * * \/bin\/find \/home\/eatat\/ -type f -iname error_log -delete<\/p>\n<\/div>\n<div class=\"lumry6a29217b2ee48\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.lumry6a29217b2ee48 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.lumry6a29217b2ee48 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.lumry6a29217b2ee48 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.lumry6a29217b2ee48 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.lumry6a29217b2ee48 {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to find and remove large error_log files generated by your scripts, while running from a Linux platform. How To Find Error_log Files In Linux List the Error Log files with its disk space usage details: # find . -type f -iname error_log -exec du -sh {} \\; type [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-248","post","type-post","status-publish","format-standard","hentry","category-server-setup"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=248"}],"version-history":[{"count":3,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/248\/revisions"}],"predecessor-version":[{"id":961,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/248\/revisions\/961"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}