Sponsored Content
Top Forums Shell Programming and Scripting <AIX>Problem in purge script, taking very very long time to complete 18.30hrs Post 302344524 by dr.house on Monday 17th of August 2009 02:18:07 AM
Old 08-17-2009
Quote:
Originally Posted by sravicha
It should be grateful if you could post the script with the logic you suggested.
Taking into consideration what has been posted by kshji, I'd rewrite the script approximately as follows, with every "schedule" representing one 'mtime', exemplified for the first three (- Linux Bash code, subject to AIX adaption):

Code:
#! /bin/bash
 
function displayState()
{
  case $2 in
  S1)
    echo "Schedule: $1 - Finding started at: $( date '+%d.%m %H.%M' )" ;;
  S2)
    echo "Schedule: $1 - Removal started at: $( date '+%d.%m %H.%M' )" ;;
  S3)
    echo "Schedule: $1 - Processing done at: $( date '+%d.%m %H.%M' )" ;;
  esac
}
 
function removeOldies()
{
  cat $1 | while read ENTRY
  do
    if [ -f $ENTRY ] # single file
    then
      rm -f $ENTRY
    elif [ -d $ENTRY ] # directory
    then
      rm -fdr $ENTRY
    fi
  done
  rm -f $1
}
 
# main function
 
displayState $1 S1
case $1 in
007)
  ${FIND} ${Purge_DIR} -type f -name '*TM-5193*' -mtime +7 -print >> stuff.list ;;
010)
  ${FIND} ${Purge_DIR} -type f \( -name '*DAILY*' -o -name '*(weekly)*' \) \
    -mtime +10 -print >> stuff.list ;;
014)
  ${FIND} ${Purge_DIR} -type f \( -name '*(WEEK)*' -o -name '*(MON)*' -o -name '*(TUE)*' \
    -o -name '*(WED)*' -o -name '*(THU)*' -o -name '*(FRI)*' -o -name '*(SAT)*' \
    -o -name '*(SUN)*' -o -name '*(WEEKLY)*' \) -mtime +14 -print >> stuff.list ;;
esac
displayState $1 S2
removeOldies stuff.list
displayState $1 S3
 
exit 0
 
# game over ;-)

Other than the original one, this script executes each "search & destroy" task individually, e.g.:

Code:
# /bin/bash kickOut.bash 014

Thus, larger tasks could be performed one by one (and at different times) as well as smaller ones in parallel (by calling the same script multiple times) - which at least should make the "monster task" less daunting Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script takes long time to complete

Hi all, I wrote this shell script to validate filed numbers for input file. But it take forever to complete validation on a file. The average speed is like 9mins/MB. Can anyone tell me how to improve the performance of a shell script? Thanks (12 Replies)
Discussion started by: ozzman
12 Replies

2. UNIX for Dummies Questions & Answers

fetchmail taking long time to fetchmail...

Hi peeps, We are having around 60 users. The time set to retrieve the mail is 300 sec. But it's taking around 1 hour to deliver mails. I am using debian sarge 3.1. any clues? And how it will affect if I decrease the time? My machine has got 1 p4 3.0 GHZ processor and 1 GB ram. The home... (2 Replies)
Discussion started by: squid04
2 Replies

3. Red Hat

login process taking a long time

I'm having a bit of a login performance issue.. wondering if anyone has any ideas where I might look. Here's the scenario... Linux Red Hat ES 4 update 5 regardless of where I login from (ssh or on the text console) after providing the password the system seems to pause for between 30... (4 Replies)
Discussion started by: retlaw
4 Replies

4. UNIX for Dummies Questions & Answers

gref -f taking long time for big file

grep -f taking long time to compare for big files, any alternate for fast check I am using grep -f file1 file2 to check - to ckeck dups/common rows prsents. But my files contains file1 contains 5gb and file 2 contains 50 mb and its taking such a long time to compare the files. Do we have any... (10 Replies)
Discussion started by: gkskumar
10 Replies

5. UNIX for Dummies Questions & Answers

Job is taking long time

Hi , We have 20 jobs are scheduled. In that one of our job is taking long time ,it's not completing. If we are not terminating it's running infinity time actually the job completion time is 5 minutes. The job is deleting some records from the table and two insert statements and one select... (7 Replies)
Discussion started by: ajaykumarkona
7 Replies

6. Solaris

How to find out bottleneck if system is taking long time in gzip

Dear All, OS = Solaris 5.10 Hardware Sun Fire T2000 with 1 Ghz quode core We have oracle application 11i with 10g database. When ever i am trying to take cold backup of database with 55GB size its taking long time to finish. As the application is down nobody is using the server at all... (8 Replies)
Discussion started by: yoojamu
8 Replies

7. UNIX for Dummies Questions & Answers

ls is taking long time to list

Hi, All the data are kept on Netapp using NFS. some directories are so fast when doing ls but few of them are slow. After doing few times, it becomes fast. Then again after few minutes, it becomes slow again. Can you advise what's going on? This one directory I am very interested is giving... (3 Replies)
Discussion started by: samnyc
3 Replies

8. Shell Programming and Scripting

While loop problem taking too long

while read myhosts do while read discovered do echo "$discovered" done < $LOGFILE | grep -Pi "|" | egrep... (7 Replies)
Discussion started by: SkySmart
7 Replies

9. Shell Programming and Scripting

Wget takes a long time to complete

Hi, I wish to check the return value for wget $url. However, some urls are designed to take 45 minutes or more to return. All i need to check if the URL can be reached or not using wget. How can i get wget to return the value in a few seconds ? (8 Replies)
Discussion started by: mohtashims
8 Replies

10. Shell Programming and Scripting

Script takes too long to complete

Hi, I have a lengthy script which i have trimmed down for a test case as below. more run.sh #!/bin/bash paths="allpath.txt" while IFS= read -r loc do echo "Working on $loc" startdir=$loc find "$startdir" -type f \( ! -name "*.log*" ! -name "*.class*" \) -print | while read file do... (8 Replies)
Discussion started by: mohtashims
8 Replies
hsearch(3)						     Library Functions Manual							hsearch(3)

Name
       hsearch, hcreate, hdestroy - manage hash search tables

Syntax
       #include <search.h>

       ENTRY *hsearch (item, action)
       ENTRY item;
       ACTION action;

       int hcreate (nel)
       unsigned nel;

       void hdestroy ( )

Description
       The  subroutine is a hash-table search routine generalized from Knuth (6.4) Algorithm D.  It returns a pointer into a hash table indicating
       the location at which an entry can be found.  The item is a structure of type ENTRY (defined in the <search.h> header file) containing  two
       pointers: item.key points to the comparison key, and item.data points to any other data to be associated with that key.	(Pointers to types
       other than character should be cast to pointer-to-character.)  The action is a member of an enumeration type ACTION indicating the disposi-
       tion  of  the  entry  if  it cannot be found in the table.  ENTER indicates that the item should be inserted in the table at an appropriate
       point.  FIND indicates that no entry should be made.  Unsuccessful resolution is indicated by the return of a NULL pointer.

       The subroutine allocates sufficient space for the table, and must be called before is used.  The nel is an estimate of the  maximum  number
       of  entries  that  the  table  will contain.  This number may be adjusted upward by the algorithm in order to obtain certain mathematically
       favorable circumstances.

       The subroutine destroys the search table, and may be followed by another call to

Restrictions
       Only one hash search table may be active at any given time.

Diagnostics
       The subroutine returns a NULL pointer if either the action is FIND and the item could not be found or the action is ENTER and the table	is
       full.

       The subroutine returns zero if it cannot allocate sufficient space for the table.

See Also
       bsearch(3), lsearch(3), string(3), tsearch(3)

																	hsearch(3)
All times are GMT -4. The time now is 03:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy