Thursday, September 2, 2010

How to delete files older than x days in Linux

To delete files older than 30 days in folder /home/user/path enter the command:
find /home/user/path -mtime +30 -exec rm {} \;
To delete also subdirectories enter the command:
find /home/user/path -mtime +30 -exec rm -rf {} \;

No comments:

Post a Comment