Hi
I need a script that will remove the contents out of a common named folder on our server and all its contents.
We have folder called temp which resides within several different folders and i need to delete the contents at a set time in the night
thanks
Treds
type:
crontab -e
as the requisite user, and enter something like:
0 1 * * * rm -rf /path/to/folder/* 2>/dev/null
Where "0" is zero minutes (ie on the hour), "1" is 1am, and /path/to/folder is the directory.
there are hundreds of folders in different locations, needs to search file system for name then delete
thanks
Treds
0 1 * * * find /path -name "dirname" -type d -exec rm -rf {} \; 2>/dev/null
thanks for the last post citaylor, can i extend this
I have folders automated created where people dump files into. But i would like to automate the deleting with a cron.
Folders are dates eg
2011-01-17
2011-02-29
what i like to do is remove all the 01 at the end of one month then all the 02 the next .....
using your script can i extended this to do this function...
I tried to put a * after the 2011-01* but that did not work
find /gpfs/SHARED/Studios_Share/ -name ".2011-01" -type d -exec rm -rf {} \; 2>/dev/null
any ideas will be grateful takes us ages every month to clear
Treds
-name "2011-01*" should work fine (make sure the asterisk is escaped or quoted as in my example)
Hi
sorry it does not work
find /gpfs/SHARED/Studios_Share/ -name "2011-01*" -type d -exec rm -rf {} \; 2>/dev/null
any other ideas
thanks for looking at this anyway
treds
If you run:
find /gpfs/SHARED/Studios_Share/ -name "2011-01*" -type d -print
from the command line, does that work ?