Hi,
i want to zip the files that generates automatically
every few minutes (files generated are in .arc
extension)....any body write a script for this...
thanks in advance

Answer Posted / narendrasairam

One way is to keep the code snippet in while loop with a
sleep time of 300 seconds (expecting 5 minutes time gap)


while true
do
FILE_EXIST_CHECK=`ls -l | grep ^- | wc -l`
if [ $FILE_EXIST_CHECK -ne 0 ];
then
if [ -f *.arc ];
then
ls *.arc > arc_files.lst
while read arc_filename
do
/usr/local/bin/gzip $arc_filename > /dev/null 2>&1
done < arc_files.lst
fi
else
echo " There are no .arc files existing...."
fi
sleep 300;
done

The other way is to schedule the job using crontab with a
time slice of minutes with out keeping in while true loop.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the first line in every perl script called?

557


how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?

3605


How to calculate the number of passed arguments?

556


What is shell scripting used for?

574


Is shell scripting a programming language?

579






What are script files?

552


How do I stop script errors?

576


How to print all the arguments provided to the script?

557


Calculate a real number calculation directly from the terminal and not any shell script.

659


I have 2 files and I want to print the records which are common to both.

699


What is the difference between break and continue commands?

576


What is bash coding?

501


Explain about login shell?

636


What is shell prompt?

566


What is the significance of $#?

593