"Remove file if older than ..." Help with a script
Hello all,
I need an expert to help me with a script to check in "FolderA" if there are files older than "x number of days", if found to remove them. Thanks in advance for any help. |
Code:
find /some/folder -mtime +28 -exec rm -f {}\; |
Quote:
Code:
find /some/folder -mtime +28 -exec rm -f {} \; |
Quote:
|
Thanks for the replies. I havn't hada chance to test it, but I will soon.
|
Remove files out of 14 days
Hello All;
I used a code "find /some/folder -mtime +14 -exec rm -f {}\;" This code can been remove files out of 14 days. howerver, the output of file is different day. You can see the file "20100830.txt" on 30, Aug on other file "www20100830.tar.gz" on 31, Aug. Please, see the further files as below: I can not remove these two files on the same day. Please, anyone can provide advise and deeply appreciated. Thanks [root@cron01]# ls -la drwxr-xr-x 3 root root 3072 Sep 13 10:23 . drwxr-xr-x 3 root root 80 Jun 22 11:31 .. drwxr-xr-x 2 root root 2048 Sep 13 10:23 httpd -rw-r--r-- 1 root root 10540589305 Aug 30 04:36 20100830.txt -rw-r--r-- 1 root root 10674572196 Aug 31 04:37 20100831.txt -rw-r--r-- 1 root root 10802965259 Sep 1 04:37 20100901.txt -rw-r--r-- 1 root root 10924710265 Sep 2 04:38 20100902.txt -rw-r--r-- 1 root root 11055977612 Sep 3 04:37 20100903.txt -rw-r--r-- 1 root root 11184724742 Sep 4 04:38 20100904.txt -rw-r--r-- 1 root root 11295158114 Sep 5 04:39 20100905.txt -rw-r--r-- 1 root root 1860313830 Aug 31 04:41 www20100830.tar.gz -rw-r--r-- 1 root root 1893674818 Sep 1 04:42 www20100831.tar.gz -rw-r--r-- 1 root root 1888460332 Sep 2 04:42 www20100901.tar.gz -rw-r--r-- 1 root root 1865787227 Sep 3 04:42 www20100902.tar.gz -rw-r--r-- 1 root root 1995716158 Sep 4 04:43 www20100903.tar.gz -rw-r--r-- 1 root root 1654560845 Sep 5 04:43 www20100904.tar.gz -rw-r--r-- 1 root root 1853689856 Sep 6 04:37 www20100905.tar.gz |
don't actually understand what you want, but i am sure you can do something about the "www" files before you find and remove. maybe store them to some other directories?
|
I think you want the daystart option?
Code:
-daystart |
Hi Acid and ghostdog74;
Thank you for your reply and kindly assistance. Actullay I want to keep 14 days log files and remove log files out of 14 days. The "*.txt" files and "*.gz" files are not create at the same day. I have different to keep same files at same day. (eg. Sep 5 04:39 20100905.txt ,,,Sep 6 04:37 www20100905.tar.gz ) Thank you |
All times are GMT -5. The time now is 03:48 AM. |