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
What is an inode block?
When should shell programming/scripting not be used?
Why do we write bin bash in shell scripts?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.
What is path variable bash?
What's the difference between scripting and coding?
How to print the first array element?
What shell is bin sh?
How do I debug a shell script?
What is $1 in shell scripting?
What are the 3 standard streams in linux?
How does shell scripting work?
What is gui scripting?
What does .sh file contain?
What is sudo command?