LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   problem with find command in script (http://www.linuxquestions.org/questions/linux-software-2/problem-with-find-command-in-script-184909/)

cojo 05-23-2004 02:56 PM

problem with find command in script
 
I have wrote a basic shell script that look for *.bak file that hasn't been access 7 days or older in a share directory. Once it find these files, I want to execute the rm -f command to delete these files. I have set crontab to run at 11PM everynight. My problem is that it doesn't remove all the files that fit in the criteria. What am I doing wrong? Here is the script:

#!/bin/bash
# This will remove all backup files that are 7 days or older
find /export/samba/cadd2 -type f -name "*.bak" -atime +7 -exec rm -f {} \;
find /export/samba/archive -type f -name "*.bak" -atime +7 -exec rm -f {} \;


I added this line in my crontab file

0 22 * * * root /sbin/rmbackup.sh

homey 05-23-2004 04:02 PM

I wonder if you would have better luck with mtime...

Code:

#!/bin/bash
# This will remove all backup files that are 7 days or older
find /export/samba/cadd2 -type f -name '*.bak' \
-mtime +7 -exec rm {} \;


cojo 05-23-2004 05:44 PM

thanks for the replied homey. I will give it a try with -mtime tonight. I'll let you know the outcome

cojo 05-26-2004 10:28 AM

Ok, I tried -mtime on the script and still doesn't do any good. Any idea anyone????


All times are GMT -5. The time now is 04:14 AM.