« disabling spamassassin in plesk for individual mailboxes. | Main | nobodycheck.sh »

a bash script to delete files older than 7 days.

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, which will delete (or "remove") the files.

TrackBack

TrackBack URL for this entry:
http://www.ramblingsofasysadmin.com/cgi-bin/mt/mt-tb.cgi/16

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)