Remove old files (*nix commandline)
Other day I needed to remove quite a few old files, modified X days ago
/var/www/htdocs/disttool/filedata# ls -lah
-rw-r--r-- 1 www-data www-data 15M 2007-10-12 15:41 349
...
-rw-r--r-- 1 www-data www-data 44M 2008-12-10 11:48 510
File names are 349 interated up to 510 in this case
So how to remove every file older than 2 days?
#find /var/www/htdocs/disttool/filedata/ -mtime +2 -exec rm {} \;
I recomend replacing "-exec rm" with "-exec ls -lah" before rm'ing..
rm will *not* ask for confirmation during delete..
Platform is Debian
Cheers!
/var/www/htdocs/disttool/filedata# ls -lah
-rw-r--r-- 1 www-data www-data 15M 2007-10-12 15:41 349
...
-rw-r--r-- 1 www-data www-data 44M 2008-12-10 11:48 510
File names are 349 interated up to 510 in this case
So how to remove every file older than 2 days?
#find /var/www/htdocs/disttool/filedata/ -mtime +2 -exec rm {} \;
I recomend replacing "-exec rm" with "-exec ls -lah" before rm'ing..
rm will *not* ask for confirmation during delete..
Platform is Debian
Cheers!
0 Comments:
Skicka en kommentar
<< Home