Archive large debug files without cp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archive large debug files without cp
# 1  
Old 04-08-2008
Archive large debug files without cp

Need some fine tuning advice:

I have a KSH programs croned to execute once a day. Which basically does the following simple operation:

for i in `ls`
do
cp $i $i.backup
>$i
gzip $i.backup
done


Basically cleanup the file after taking a backup.

Now the issue here is this directory will contain more than 12 files with >1GB each file and gets very nasty all time.

I considered an approach like

1. tar -cvf debug.tar ~/debug
2. > [All the files]

This approach also creates problem because there will be a big time gap between step 1 and 2. so all the info written between 1 and 2 will be lost.

Any advice on this?
# 2  
Old 04-08-2008
maybe do a mv rather than cp, then gzip, and then "touch $i" to create a new file?
# 3  
Old 04-08-2008
CPU & Memory Use Find command and tar for this.

Hey, use the "FIND" command along with tar command to zip the files greater than the specified size.
Go to the specified directory and execute the following command.....

Here is an eg :
find . -type f -size +1000 2>/dev/null | xargs tar -cvf testingtar.tar


What this basically does it
1> It finds all the files that are greater than 1000 blocks.
2> We collect all those through xargs (which is the faster than others)
3> We tar all those files.

2>/dev/null is used so that the error messages are not displayed.....


It works quickly and i believe this is the better way to use it.


Let me know if you need any.......
# 4  
Old 04-08-2008
Age 79/Helper, Thanks for response. Both the ideas suggested gone in my mind already, especially the Age79 approach.

However, what I'm concerned is that If I do

mv $i
touch $i

This may have an impact on the C++ program as the file handler changes internally? Am I talking sense?

Helper,
find . -type f -size +1000 2>/dev/null | xargs tar -cvf testingtar.tar

Is good but still it's not recovering the demerit I've mentioned. As I have to cleanup the files also using ">" probably, I'll loose some data when I cleanup after the above operation.


Anyway, goog points. Appreciated.
# 5  
Old 04-08-2008
Ideally the application should have a way to make it close and reopen its log file precisely for this reason.
# 6  
Old 04-08-2008
100% agreeing to it. This is like a legacy application running in production and don't have a way to alter it. Otherwise I would prefer a log rotation kind of mechanism which creates new log file everyday! :-) We can archive the rest of stuffs safely then.

Anyway.. This is what it is. :-)

Cheers
F
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check files and archive the files using sftp

Hi, I have to check the files in another server using sftp to do that, below is the code i am going with #!/bin/bash export SRC_FOLDER=$1 export ARC_FOLDER=$2 HOST=as07u3456 USER=relfag sftp ${USER}@${HOST} <<EOF cd $SRC_FOLDER/DSCOR ls bye EOF echo "done" whatever the files i... (8 Replies)
Discussion started by: ursrami
8 Replies

2. UNIX for Dummies Questions & Answers

How to archive old files from the recently added 10 files?

Hi there, I am very new to unix and having trouble with a fairly simple statement: cd /user ls -t -c1 | sed -ne '11,$p' | mv xargs archive/ What I want the code to do is sort all files in a directory by timestamp, select all of the files after the 10th file, and then move those files... (3 Replies)
Discussion started by: DSIReady
3 Replies

3. Shell Programming and Scripting

Archive files which has more than one row

Hello Guys Please treat this as urgent . Can you please kindly help me to know how to archive files in a directory which has more than one row Thanks for your time and help!! (3 Replies)
Discussion started by: Pratik4891
3 Replies

4. Solaris

How to safely copy full filesystems with large files (10Gb files)

Hello everyone. Need some help copying a filesystem. The situation is this: I have an oracle DB mounted on /u01 and need to copy it to /u02. /u01 is 500 Gb and /u02 is 300 Gb. The size used on /u01 is 187 Gb. This is running on solaris 9 and both filesystems are UFS. I have tried to do it using:... (14 Replies)
Discussion started by: dragonov7
14 Replies

5. Shell Programming and Scripting

Divide large data files into smaller files

Hello everyone! I have 2 types of files in the following format: 1) *.fa >1234 ...some text... >2345 ...some text... >3456 ...some text... . . . . 2) *.info >1234 (7 Replies)
Discussion started by: ad23
7 Replies

6. Shell Programming and Scripting

Archive Files

I have 15-20 files in a unix folder on daily basis, so i need to archive those 20 files as dated today and place that archived files in a new folder and has to remove those 20 files from that folder. so that i place 20 new files that comes for tomorrow. i need write a unix script to do this. ... (1 Reply)
Discussion started by: gaddamshashank
1 Replies

7. Solaris

Tar too large to archive. Use E function modifier.

hey all, i am trying to tar up a folder with sub folders the over all size will be about 70gb but when i use the normal command tar -cvf tar -cvf CLPSI_PRU_Escrow_31994.tar CLPSI_PRU_Escrow_31994 i get an error tar: CLPSI_PRU_Escrow_31994/dump1/PROD_SAE_jria3_dump.5 too large to archive. ... (9 Replies)
Discussion started by: dshakey
9 Replies

8. Shell Programming and Scripting

compare two files using while and sed .. debug my script please

Hi, I'm a newbie to Linux. I have not done programming before, but I accidentally stumble upon Linux scripts at work about 2 weeks ago. I got interested and write scripts to automate my job duties. I need to write a script to compare 2 files (very long list) side by side so it's easier to... (10 Replies)
Discussion started by: shamushamu
10 Replies

9. Shell Programming and Scripting

Archive script old files

Hi All, Im trying to write a script to archive files based on the date the files were created. For example, if a group of files were created on 23rd August,I would have 230806.tar. I have a problem,I want the script to read a separately created file(readarchive.txt) to look for the path to... (1 Reply)
Discussion started by: kayarsenal
1 Replies

10. Shell Programming and Scripting

Archive files

Hi All, I wrote this script: #!/bin/ksh while read DAYS ARCH_PATH do cd $ARCH_PATH find . \( -type d ! -name . -prune \) -o -type f -mtime +$DAYS -exec tar -cv f kay_`date +%d%m%y%H%M`.tar {} \; cd - done < filestoarchive.txt The problem is, in a folder of 7files, I would... (13 Replies)
Discussion started by: kayarsenal
13 Replies
Login or Register to Ask a Question