Gzip behavior on open files?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Gzip behavior on open files?
# 8  
Old 04-28-2013
Quote:
Originally Posted by alister
The way this is typically done during logrotation is to rename the logfile, then send a signal to the logging process to inform it that it needs to close its file descriptor and create a new logfile, and finally, compress.

Another safe alternative, though more brutish, is to shut down the logging process during rotation.
Yes this is what I thought. The problem is that the logging process is basically a black box as far as I'm concerned. I don't know if it holds a file descriptor, or just keeps atomically opening-appending-closing the file, nor do I know if it would respond to signals. It's also not possible to shut down the logging process, for various reasons but mainly because the traffic is real-time and needs to be logged as such.

Looks like there's no way to do what I need without the logging process explicitly cooperating. I guess the next best approach would be to strip only data out of the capture which definitely appears in the gz after the archiving is complete. And that's something I have no clue how to do yet... stay tuned for another thread Smilie
# 9  
Old 04-28-2013
FWIW - most "logging" processes that follow UNIX standards will close the current output file and then open another on receipt of a SIGHUP signal. Check your documentation.
# 10  
Old 04-28-2013
Quote:
Originally Posted by dan-e
Looks like there's no way to do what I need without the logging process explicitly cooperating.
You could try moving the file out of the way, as you thought of long before and I explained might actually work...
# 11  
Old 04-29-2013
Quote:
Originally Posted by Corona688
You could try moving the file out of the way, as you thought of long before and I explained might actually work...
Yeah but if it does happen to crash the process(es) dumping to the capture files, worst case scenario - it could result in a nationwide temporary SMS outage costing my company millions (and I can safely assume I will be sacked) Smilie

It's probably not worth experimenting with... Smilie
# 12  
Old 04-29-2013
Quote:
Originally Posted by dan-e
It's probably not worth experimenting with... Smilie
Yikes. Point taken. Is there any way you can just ignore the files?
# 13  
Old 04-29-2013
Quote:
Yeah but if it does happen to crash the process
What if you copy the log file before using gzip on the static copy? That way you avoid any possibility for glitch.
# 14  
Old 04-29-2013
Quote:
Originally Posted by hanson44
What if you copy the log file before using gzip on the static copy? That way you avoid any possibility for glitch.
How? It could be copied in an incomplete state...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tar and gzip files

Hi Guys, I am using RHEL5 and Solaris 9 & 10. I want to tar and gzip my files then remove them after a successful tar command... Lets say I have files with extension .arc then I want to tar and gzip these files. After successful tar command I want to remove all these files (i.e .arc). ... (3 Replies)
Discussion started by: Phuti
3 Replies

2. Shell Programming and Scripting

help with a script to gzip/move files

Hi Please can you help me in writing a script to find files on a specific directory, and of extension "tap" but only of the month of september, gzip and move them to another directory. Your help will be appreciated. (4 Replies)
Discussion started by: fretagi
4 Replies

3. UNIX for Advanced & Expert Users

gzip vs pipe gzip: produce different file size

Hi All, I have a random test file: test.txt, size: 146 $ ll test.txt $ 146 test.txt Take 1: $ cat test.txt | gzip > test.txt.gz $ ll test.txt.gz $ 124 test.txt.gz Take 2: $ gzip test.txt $ ll test.txt.gz $ 133 test.txt.gz As you can see, gzipping a file and piping into gzip... (1 Reply)
Discussion started by: hanfresco
1 Replies

4. Shell Programming and Scripting

gzip files with extension

Hi, I have 1000 of files in a folder with the file extension as .csv In this some of the files are already zipped and its looks like filename.csv.gz Now i need to zip all the files in the folder to free some disk space. When i give gzip *.csv It prompts me to overwrite filename.csv.gz... (5 Replies)
Discussion started by: nokiak810
5 Replies

5. Shell Programming and Scripting

gzip the files with particular extension

Is there any way to compress only the files with .xml extension within a folder which in turn has many sub folders? gzip -r9 path/name/*.xml is not working This compression is done in the Windows server using Batch script. (2 Replies)
Discussion started by: Codesearcher
2 Replies

6. Shell Programming and Scripting

Gzip files as they are created

Hello. I have a scripting query that I am stumped on which I hope you can help with. Basically, I have a ksh script that calls a process to create n number of binary files. These files have a maximum size of 1Gb. The process can write n number of files at once (parallel operation) based on the... (4 Replies)
Discussion started by: eisenhorn
4 Replies

7. Shell Programming and Scripting

unzip particular gzip files among the normal data files

Hello experts, I run Solaris 9. I have a below script which is used for gunzip the thousand files from a directory. ---- #!/usr/bin/sh cd /home/thousands/gzipfiles/ for i in `ls -1` do gunzip -c $i > /path/to/file/$i done ---- In my SAME directory there thousand of GZIP file and also... (4 Replies)
Discussion started by: thepurple
4 Replies

8. UNIX for Dummies Questions & Answers

gzip all the files in a directory

Hi, There are multiple files in a directory with different names.How can they be gzipped such that the timestamp of the files is not changed. (2 Replies)
Discussion started by: er_ashu
2 Replies

9. UNIX for Dummies Questions & Answers

Need to gzip LARGE files

The windows version of gzip supports pretty much unlimited file sizes while the one we have in solaris only goes up to a set size, one or two gigs I think. Is there a new version of gzip I can put on our systems that supports massive file sizes? (2 Replies)
Discussion started by: LordJezo
2 Replies

10. UNIX for Dummies Questions & Answers

gzip, multiple files

Hello Everyone, Here is what I am trying to do. I have four text files, I want to gzip them under unix and mail the zipped file via outlook. I am able to do this easily enough, but using winzip or pkunzip to unzip the file, there is only one file. (In essence, all four files were... (2 Replies)
Discussion started by: smbodnar
2 Replies
Login or Register to Ask a Question