|
|
Question : Script to delete folders which are 30 days older than current date
|
|
Hi,
I need a script which shall purge folders which are older than 30 days from the current date. Hence for example if today is 08/22/2007 then anything which is before 07/23/2007 should be deleted. The script needs to take account of february (leap year), 31 days etc. An actual example shall be helpful. The script needs to be in korn shell. The servers on which the files are located are SUN OS Servers.
Thanks in advance
|
Answer : Script to delete folders which are 30 days older than current date
|
|
Presumably the directories (folders) are going to be empty? If so, then doing
find /path/to/dirs -mtime +30 -type d -depth -exec rmdir {} \;
should work fine.
-mtime +30 match any dirs with a modificate time older than 30 days -type d match only directories -depth descend the directory first so that top level directories aren't processes first -exec rmdir {} remove the matched directory.
|
|
|
|