{"id":5943,"date":"2017-09-19T12:09:03","date_gmt":"2017-09-19T12:09:03","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=5943"},"modified":"2021-01-30T10:09:08","modified_gmt":"2021-01-30T10:09:08","slug":"clean-tmp-folder-contents-linux-servers","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/","title":{"rendered":"How to clean up the \/tmp folder contents on Linux servers"},"content":{"rendered":"<p><span style=\"color: #000000;\">Each Linux server has a diretcory named \/tmp which is installed with individual file system. it is used to hold temporary files. \/tmp directory have all the all the website session files which is hosted on serve.<\/span><!--more--><\/p>\n<p><span style=\"color: #000000;\">so if we removed those file incorrectly the user session got disconnected who is currently using database. Some times the \/tmp directory got full, so you can\u2019t write anything to mysql database and you start getting error messages. To resolve this you have to remove some content\/files from <a href=\"https:\/\/cpanelplesk.com\/wp62\/how-to-increase-size-of-tmp-on-cpanel-server\/\">\/tmp directory<\/a> to free space.<\/span><\/p>\n<p><span style=\"color: #000000;\">First of all you can check \/tmp directory to find out what kind of files stored there.<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>root@server [\/tmp]# ls -lh\r\ntotal 50M\r\ndrwxrwxrwt 15 root root 508K May 6 13:26 .\/\r\ndrwxr-xr-x 29 root root 4.0K May 3 03:32 ..\/\r\n-rw------- 1 cppl cppl 1.8K 19 Sep 6 05:48 sess_01677a0944c23187135748f09037f13a\r\n-rw------- 1 cppl cppl 19 Sep 6 13:22 sess_0292d1af394d15f09e5565af76304acd<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">In my server <a href=\"https:\/\/cpanelplesk.com\/wp62\/mysql-error-cant-createwrite-to-file-tmpsql_839_1-myi-errcode-28-error-number-1\/\">\/tmp<\/a> folder have only session file, so i\u2019m going to remove only session files.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Shell script to clean session files:<\/span><\/h3>\n<p><span style=\"color: #000000;\">For this purpose we can use the simple shell script and assign to cron once in a day.<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>#!\/bin\/bash\r\n\r\nrm -rf \/tmp\/sess_*\r\n\/sbin\/service mysql restart<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">Just create the shell file called tmpclean.sh at <strong>\/etc\/cron.daily<\/strong> folder and put the above codes. It will clean the session files once in a day and restart the mysql service.<\/span><br \/>\n<span style=\"color: #000000;\"> Make sure your shell file have executable permissions (755).<\/span><\/p>\n<h3><span style=\"color: #000000;\">Clean \/tmp folder without affecting anything ?<\/span><\/h3>\n<p><span style=\"color: #000000;\">Many script creates session files after every seconds. You can use mtime argument with the find command to search out little bit old files say 1 hour older. So if you remove them it doesn&#8217;t effect much to your websites.<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>#!\/bin\/bash\r\n\r\nfind \/tmp\/sess_* -mtime +1h -exec rm {} \\;<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">Just create the shell file called tmpclean.sh at <strong>\/etc\/cron.hourly<\/strong> folder and put the above codes. It will clean the session files every one hour. Make sure your shell file should have executeable permission (755).<\/span><\/p>\n<p><span style=\"color: #000000;\">That\u2019s all we have to do clean up the \/tmp folder contents in Linux servers\u00a0 Please give your opinion below if you experience any issues or to discuss your ideas and\u00a0experiences.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Each Linux server has a diretcory named \/tmp which is installed with individual file system. it is used to hold temporary files. \/tmp directory have all the all the website session files which is hosted on serve. [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,14],"tags":[],"class_list":["post-5943","post","type-post","status-publish","format-standard","hentry","category-cpanel","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"Each Linux server has a diretcory named \/tmp which is installed with individual file system. it is used to hold temporary files. \/tmp directory have all the all the website session files which is hosted on serve. [...]Continue Reading...\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seemab Saleem\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\"},\"author\":{\"name\":\"Seemab Saleem\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\"},\"headline\":\"How to clean up the \/tmp folder contents on Linux servers\",\"datePublished\":\"2017-09-19T12:09:03+00:00\",\"dateModified\":\"2021-01-30T10:09:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\"},\"wordCount\":318,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"articleSection\":[\"Cpanel\",\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\",\"name\":\"How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"datePublished\":\"2017-09-19T12:09:03+00:00\",\"dateModified\":\"2021-01-30T10:09:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to clean up the \/tmp folder contents on Linux servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\",\"name\":\"Seemab Saleem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"caption\":\"Seemab Saleem\"},\"description\":\"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!\",\"sameAs\":[\"https:\/\/cpanelplesk.com\/wp62\"],\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk","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:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/","twitter_card":"summary_large_image","twitter_title":"How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk","twitter_description":"Each Linux server has a diretcory named \/tmp which is installed with individual file system. it is used to hold temporary files. \/tmp directory have all the all the website session files which is hosted on serve. [...]Continue Reading...","twitter_misc":{"Written by":"Seemab Saleem","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/"},"author":{"name":"Seemab Saleem","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648"},"headline":"How to clean up the \/tmp folder contents on Linux servers","datePublished":"2017-09-19T12:09:03+00:00","dateModified":"2021-01-30T10:09:08+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/"},"wordCount":318,"commentCount":0,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"articleSection":["Cpanel","Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/","url":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/","name":"How to clean up the \/tmp folder contents on Linux servers - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"datePublished":"2017-09-19T12:09:03+00:00","dateModified":"2021-01-30T10:09:08+00:00","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/clean-tmp-folder-contents-linux-servers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"How to clean up the \/tmp folder contents on Linux servers"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648","name":"Seemab Saleem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","caption":"Seemab Saleem"},"description":"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!","sameAs":["https:\/\/cpanelplesk.com\/wp62"],"url":"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/5943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=5943"}],"version-history":[{"count":0,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/5943\/revisions"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=5943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=5943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=5943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}