{"id":2940,"date":"2018-12-13T16:40:55","date_gmt":"2018-12-13T14:40:55","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=2940"},"modified":"2018-12-13T16:55:14","modified_gmt":"2018-12-13T14:55:14","slug":"delete-files-older-than-x-days-on-linux","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=2940","title":{"rendered":"Delete Files Older Than x Days on Linux"},"content":{"rendered":"<p>find \/home\/ftp\/services\/* -mtime +5 -exec rm {} \\;<\/p>\n<ul>\n<li>The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.<\/li>\n<li>The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.<\/li>\n<li>The third argument, -exec, allows you to pass in a command such as rm. The {} \\; at the end is required to end the command.<\/li>\n<\/ul>\n<p>find \/home\/ftp\/services\/* -type f -name &#8216;*.jpg&#8217; -mtime +30 -exec rm {} \\;<\/p>\n<p>find \/home\/ftp\/services\/* -mtime +180 -size +1G -exec rm {} \\;<\/p>\n<p>find \/home\/ftp\/services\/* -mtime +180 -size +100M -exec rm {} \\;<\/p>\n<p>This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>find \/home\/ftp\/services\/* -mtime +5 -exec rm {} \\; The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2843,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2940"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2940"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2940\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2843"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}