{"id":50,"date":"2014-02-03T22:18:00","date_gmt":"2014-02-03T22:18:00","guid":{"rendered":"http:\/\/369@jodohost.com\/\/blog\/"},"modified":"2014-02-03T22:18:00","modified_gmt":"2014-02-03T22:18:00","slug":"argument-list-too-long-deleting-the-file-or-directory-using-its-inode-number","status":"publish","type":"post","link":"http:\/\/www.jodohost.com\/blog\/index.php\/2014\/02\/03\/argument-list-too-long-deleting-the-file-or-directory-using-its-inode-number\/","title":{"rendered":"Argument list too long? Deleting the file or directory using its inode number"},"content":{"rendered":"<p>We&#8217;ve noticed that sometimes a file or directory has a really big size due to which removing it is not possible<br \/>and you get the message below:- <\/p>\n<p>Argument list too long \\*<\/p>\n<p>This issue certainly happens with everyone and especially with the folder &#8220;Session&#8221;, where all the sessions of the server in a directory are kept. Recently I&#8217;ve faced this issue on an Linux server where the user stores the server&#8217;s sessions files at the location below:- <\/p>\n<p>[root@server]# pwd<br \/>\u00a0\/var\/lib\/sessions<br \/>[root@server lib]# cd \/var\/lib\/<br \/>[root@server lib]# ls -al <br \/>drwxrwxrwx.\u00a0 4 root\u00a0 root\u00a0 32875698 Nov 22 15:20 session<\/p>\n<p>And I tried every possible way to remove the files inside it with the following commands:- <\/p>\n<p>rm -rf session\/*\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (remove all files inside the session directory)<br \/>find session\/ -type f -name &#8220;*.sess&#8221; -exec rm {} ; \u00a0 \u00a0\u00a0 (removing files whose names end as .sess)<br \/>find session\/* -mtime +50 -exec rm {} \\;\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0 (removing files 50 days old)<\/p>\n<p>But all give the same output as below after 1 hour:- <\/p>\n<p>Argument list too long \\*<\/p>\n<p>At last, I tried the way which did remove the directory very quickly for me. I used the help of its inode number.<\/p>\n<p>Step 1: Check the inode number of the directory using the command below:- <\/p>\n<p>[root@server lib]# ls -li<\/p>\n<p>1179686 drwxrwxrwx. 4 root\u00a0 root\u00a0 32875698 Nov 22 15:20 session<\/p>\n<p>Above the first number, i.e. 1179686, is the inode of the directory session. Now remove the directory using the inode number with the command below:- <\/p>\n<p>[root@server lib]# find . -inum 1179686 -exec rm -rf {} \\;<\/p>\n<p>&#8220;No such file or directory.&#8221;<\/p>\n<p>And that&#8217;s it! The directory will be removed and after a few seconds you&#8217;ll get the message as above. That&#8217;s all!<\/p>\n<p> ]]><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve noticed that sometimes a file or directory has a really big size due to which removing it is not possibleand you get the message below:- Argument list too long \\* This issue certainly happens with everyone and especially with the folder &#8220;Session&#8221;, where all the sessions of the server in a directory are kept. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/50"}],"collection":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":0,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}