PDA

View Full Version : [ubuntu] Automatically delete files older than 6 months in folder



rado3105
March 27th, 2010, 03:38 PM
I have server running ubuntu. There is folder /var/netflow and I have there files, which creates every 5minutes new ones(monitoring traffic on network). And I need to delete files older than 6 months manually. Can you help?

CharlesA
March 27th, 2010, 04:52 PM
I actually had this bookmarked somewhere...

Check here (http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/).

fang0654
March 27th, 2010, 04:58 PM
You can use the find command for that:



find /var/netflow -ctime +180 -delete


This will delete any files created over 180 days ago in the /var/netflow folder (and all subfolders).

Add this to a cron job and it will be automatic.