The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compress files indira UNIX for Dummies Questions & Answers 3 05-29-2007 08:23 PM
Compress multiple files sbasetty Shell Programming and Scripting 5 04-29-2007 07:53 PM
How to compress & delete files in ksh vkumar Shell Programming and Scripting 4 01-22-2007 09:36 AM
How to Compress log files? redlotus72 UNIX for Dummies Questions & Answers 1 02-23-2005 02:07 AM
compress files lesstjm Shell Programming and Scripting 1 11-06-2001 07:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2005
Registered User
 

Join Date: Oct 2005
Posts: 6
Question Compress all INACTIVE Files

Hi gurus,

I have a batch job running daily night automatically. The job produces file with extension '.0' like a.0, b.0 etc.

Now due to file space constraints, most of the time, the job fails with insufficient disk space and then we have to manually start the job again and keep running the gzip/compress command on all the *.0 files (to compress them and make way for more files) which are not used by the backup job.

Now can you please help me in creating the shell script for this.

All I want my script to do this -

1. Fuser .0 one by one.
2. If the file is active then proceed with next .0 file.
3. If the file is not active (I mean if fuser does not report any process locking the file) then run the compress in background.

Pls. help
Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-17-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,861
Code:
cd /path/to/files
for filename in `ls -1 *.0`
do
	echo "`fuser $filename`" | grep -q "$filename"
	if [ $? -ne 0 ]; then
	   compress $filename
	fi
done
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0