Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 the advantages of shell script?

1033


Given a file find the count of lines containing the word "abc".

1562


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

1231


c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again

6464


wats the deinitions for shell utility and filter?

2327


How do I run a powershell script?

1147


How do I run a bin bash script?

1046


What is bash used for?

1018


Can shell script run on windows?

1078


What are the types of script?

1184


Write a script to print the first 10 elements of fibonacci series.

2352


What is wc in shell script?

998


What are the different types of commonly used shells on a typical linux system?

1103


What is an inode block?

1068


What are the different communication commands available in the shell?

977