telmehow
05-18-2008, 10:36 PM
Hi Guys,
Can really use your help in getting a cronjob working. I have a reseller account (Hsphere), under which I am running a FTP server on a Linux account.
Here are the requirements
Under ftp root I have the DIR_SP, Dir A, Dir B, Dir C…….
I want to delete any files / sub directories older than 14 days, but would like to skip one special director (DIR_SP), also I want all the files and sub-directories under the other directories deleted, but not the directory themselves (in other words, delete all the files and sub-dirs under DirA, but not the DirA itself). Here is what I have so far and it works:
find . -name DIR_SP -prune -o -mtime +14 -exec rm -rf {} \;
but for some reason, I cannot get the other part working (delete all the files and sub-dirs under DirA,DirB, DirC… but not the directory itself). If I execute this command, it will delete any old directory as well (DirA, DirB…). I tried,
find . -name DIR_SP -prune -o -mtime +14 -depth +1 -exec rm-rf {} \;
but adding the ‘-depth +1’ gives me a find error (find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]).
Thanks in advance.
SM
Can really use your help in getting a cronjob working. I have a reseller account (Hsphere), under which I am running a FTP server on a Linux account.
Here are the requirements
Under ftp root I have the DIR_SP, Dir A, Dir B, Dir C…….
I want to delete any files / sub directories older than 14 days, but would like to skip one special director (DIR_SP), also I want all the files and sub-directories under the other directories deleted, but not the directory themselves (in other words, delete all the files and sub-dirs under DirA, but not the DirA itself). Here is what I have so far and it works:
find . -name DIR_SP -prune -o -mtime +14 -exec rm -rf {} \;
but for some reason, I cannot get the other part working (delete all the files and sub-dirs under DirA,DirB, DirC… but not the directory itself). If I execute this command, it will delete any old directory as well (DirA, DirB…). I tried,
find . -name DIR_SP -prune -o -mtime +14 -depth +1 -exec rm-rf {} \;
but adding the ‘-depth +1’ gives me a find error (find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]).
Thanks in advance.
SM
