{"id":19,"date":"2006-07-10T11:08:41","date_gmt":"2006-07-10T11:08:41","guid":{"rendered":"http:\/\/ramblingsofasysadmin.com\/blog\/?p=19"},"modified":"2006-07-10T11:08:41","modified_gmt":"2006-07-10T11:08:41","slug":"a-bash-script-to-delete-files-older-than-7-days","status":"publish","type":"post","link":"http:\/\/ramblingsofasysadmin.com\/?p=19","title":{"rendered":"a bash script to delete files older than 7 days."},"content":{"rendered":"<p>i would like to share this nifty little script, courtesy of a forum post on <a href=\"http:\/\/www.linuxquestions.org\/questions\/showthread.php?t=462290\" target=\"_new\">linuxquestions.org<\/a>, one of the most authoritative websites on linux genius and learning.<br \/>\n<font face=\"courier\"><br \/>\n#!\/bin\/bash<br \/>\nfind \/directoryname -type f -mtime +7 -exec rm {} \\;<br \/>\n<\/font><br \/>\nthis script will find all the files that are older than 7 days (as indicated by <font face=\"courier\">mtime +7<\/font> in the <font face=\"courier\">\/directoryname<\/font> folder (note: it is advisable to use an absolute path here) and execute the <font face=\"courier\">rm<\/font> command, which will delete (or &#8220;remove&#8221;) the files.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>i would like to share this nifty little script, courtesy of a forum post on linuxquestions.org, one of the most authoritative websites on linux genius and learning. #!\/bin\/bash find \/directoryname -type f -mtime +7 -exec rm {} \\; this script will find all the files that are older than 7 days (as indicated by mtime +7 in the \/directoryname folder (note: it is advisable to use an absolute path here) and execute the rm command, <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"http:\/\/ramblingsofasysadmin.com\/?p=19\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"_links":{"self":[{"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19"}],"version-history":[{"count":0,"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ramblingsofasysadmin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}