LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 12-12-2008, 06:52 AM   #1
Zypher123
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Question Delete files script using Find and Tar


Hi,

I have created a smal script in an RHEL 5.2 that finds files older than 30 days and then TARs them and deletes the files from a specific path.

the script works just great in the RHEl 5.2, now i got the job to implement the same script in an RHEL 3.6, i thought, great just copy my other script and modify some paths and voila it should work well that didnīt go so well.. the script creates a small 8 kb tgz file and leaves all the old files in there places...

here is the script:

Code:
cd /opt/delscript/

find /home/chroot/jail/* -type f -mtime +30 -print0 | xargs -0 tar czfpX /home/backup/Del_script_backup_$(date +%y%m%d).tgz Exclude --remove-files

find /home/backup/* -type f -name "Del_script_backup_*.tgz" -mtime +3 -exec rm -f {} \;
Here is the exclude file that Tar uses:

Code:
/home/backup/*

/home/chroot/*/dev/*

/home/chroot/*/etc/*

/home/chroot/*/lib/*

/home/chroot/*/usr/*

*.ssh*

*id_dsa.pub*

*id_rsa*

id_rsa.pub

*keys

*.bash_history

*.bash_logout

*.bash_profile

*.bashrc

*.gtkrc

*.kde
Anyway when i do the Find part of the script it finds all the files, but it is probably the Tar part that is different from RHEL 5 in some way that I canīt seame to find...


I appreciate any help i can get!

/Peter

Last edited by Zypher123; 12-12-2008 at 06:54 AM.
 
Old 12-12-2008, 09:45 AM   #2
Zypher123
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Solved

Hi Guys!

Well it wasnīt that hard to solve...

It is actualy embarrassing to say, there was an blank space in the end of the Exclude file... that caused Tar to Exclude all files..
Stupid me!...

/Peter
 
  


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
Using find and rm command to delete files over x days old 200mg Linux - Newbie 16 09-03-2008 06:41 PM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 03:43 PM
Delete old files script simpi Linux - Newbie 11 04-25-2008 02:37 AM
fast easy way to find old files to delete??? lowlight1177 Linux - Software 2 04-06-2006 07:35 PM
find and delete files - stupid question though smshuja Linux - Newbie 5 12-29-2005 01:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration