Hi All:
I would like to write a small shell script to be added to cronjobs, the main purpose is for the shell script is to delete the outdated files and outdated sub-directories under a certain folder, however I do not want to delete the top folder.
For example: the top folder is /proj/tmp
the command I wrote was:
“ find /proj/tmp/ -mtime +10 | xargs rm -rf ”
The problem is: once there are some files inside satisfying the find condition, "/proj/tmp/" will be returned as well.
I can't add -type f, because I would like to remove those subfolders as well.
if I revise the command as the following:
“ find /proj/tmp/* -mtime +10 | xargs rm -rf ”
it works as I expected. However, as the top folder is empty, it always report some errors like: "find /proj/tmp/*: no such file or directory". If it's added to cronjob, which will be emailed to root again and again.
Any suggestions to this problem? Thanks a lot!!!
btw: I tried with >/dev/null, which didn't help with the error message. Someone suggested tmpwatch, the problem is that I don't know which files or directories returned by tmpwatch, so that I can't test with tmpwatch.