LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-23-2004, 02:56 PM   #1
cojo
Member
 
Registered: Feb 2003
Location: St. Louis
Distribution: RedHat 8
Posts: 262

Rep: Reputation: 31
Question 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
 
Old 05-23-2004, 04:02 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
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 {} \;
 
Old 05-23-2004, 05:44 PM   #3
cojo
Member
 
Registered: Feb 2003
Location: St. Louis
Distribution: RedHat 8
Posts: 262

Original Poster
Rep: Reputation: 31
thanks for the replied homey. I will give it a try with -mtime tonight. I'll let you know the outcome
 
Old 05-26-2004, 10:28 AM   #4
cojo
Member
 
Registered: Feb 2003
Location: St. Louis
Distribution: RedHat 8
Posts: 262

Original Poster
Rep: Reputation: 31
Ok, I tried -mtime on the script and still doesn't do any good. Any idea anyone????
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 12:21 PM
Problem with the #find command jbuckley2004 Linux - General 7 08-26-2005 05:51 PM
problem with the shell command "find zosimus Linux - Software 7 06-14-2005 04:28 PM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM
same find command not working in bash script, quotes? QuakerOatz Linux - Software 1 07-14-2003 12:04 PM


All times are GMT -5. The time now is 03:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration