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 are filters explain sort with all the options available?

930


Explain about return code?

632


Explain about the slow execution speed of shells?

773


How do you know which shell I am using?

587


What is sed in shell script?

568






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

3601


How do I run a shell script in powershell?

554


What does it mean to debug a script?

569


How are shells born?

548


What is path variable bash?

566


What is shell environment?

544


How to calculate the number of passed arguments?

552


write a shell script to check the failed jobs?

3952


Is scripting and coding the same thing?

559


What is the use of echo in shell script?

537