Ignore:
Timestamp:
2010-04-29T17:25:13+12:00 (14 years ago)
Author:
sjm84
Message:

Updated to find lsof in either /usr/bin or /usr/sbin and various other small changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/mat/trunk/bin/script/mat-colbuild-download.bash

    r18210 r22002  
     1#!/bin/bash
     2
    13# if this file is executed, /bin/sh is used, as we don't start with #!
    24# this should work under ash, bash, zsh, ksh, sh style shells.
     
    1416COLLECT_DIR=$7
    1517LOG_FILE=$8
     18CACHE_DIR=$3
    1619
     20if [ -x /usr/bin/lsof ] ; then
     21  lsof=/usr/bin/lsof
     22else
     23  if [ -x /usr/sbin/lsof ] ; then
     24    lsof=/usr/sbin/lsof
     25  else
     26    echo "Warning: Unable to find 'lsof', skipping test for number of files open"
     27  fi
     28fi
    1729
    1830TOMCAT_ID=`ps ux  | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $2 }'`
    19 echo Tomcat_ID: $TOMCAT_ID
    20 #cd /usr/sbin
    21 NUM_OPEN_FILES=`/usr/sbin/lsof -p $TOMCAT_ID | wc -l `
    22 echo open files: $NUM_OPEN_FILES
    2331
    24 rm -f $LOG_FILE
     32if [ ! -z "$lsof" ] ; then
     33  echo Tomcat_ID: $TOMCAT_ID
     34  #cd /usr/sbin
     35  NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
     36  echo open files: $NUM_OPEN_FILES
     37fi
     38
    2539cd $GS3_ROOT
    2640 
     
    3448echo $1 $2 $3 $4 $5 $6 $7 $8 >> $LOG_FILE
    3549
    36 NUM_OPEN_FILES=`/usr/sbin/lsof -p $TOMCAT_ID | wc -l `
    37 echo open files: $NUM_OPEN_FILES
     50if [ ! -z "$lsof" ] ; then
     51  NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
     52  echo open files: $NUM_OPEN_FILES
     53fi
    3854
    39 if [ ! -e $3 ] # be sure the cache directory exists
     55if [ ! -e $CACHE_DIR ] # be sure the cache directory exists
    4056then
    41    mkdir $3
     57   mkdir $CACHE_DIR
    4258else
    43   /bin/rm -rf $3/*
     59   /bin/rm -rf $CACHE_DIR/*
    4460fi
    4561
    4662echo "Away to download OAI"  >> $LOG_FILE
    4763
    48 NUM_OPEN_FILES=`/usr/sbin/lsof -p $TOMCAT_ID | wc -l `
    49 echo open files: $NUM_OPEN_FILES
     64if [ ! -z "$lsof" ] ; then
     65  NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
     66  echo open files: $NUM_OPEN_FILES
     67fi
    5068
    51 downloadfrom.pl -download_mode OAI -cache_dir $3 -url $2 -max_records $4 -metadata_prefix $5 $9  2>&1 >> $LOG_FILE
     69perl -S downloadfrom.pl -download_mode OAI -cache_dir $CACHE_DIR -url $2 -max_records $4 -metadata_prefix $5 $9  2>&1 >> $LOG_FILE
    5270
    53 NUM_OPEN_FILES=`/usr/sbin/lsof -p $TOMCAT_ID | wc -l `
    54 echo open files: $NUM_OPEN_FILES
     71if [ ! -z "$lsof" ] ; then
     72  NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
     73  echo open files: $NUM_OPEN_FILES
     74fi
    5575
    5676
Note: See TracChangeset for help on using the changeset viewer.