Solaris 10
ksh88
Sorry for re-hashing some of this, but I can't find a proper solution in the forums.
Starting with /a/archive containing (on and on date formatted directories)
20060313 20080518 20100725 20121015
20060314 20080519 20100726 20121107
20060315 20080520 20100727 20121109
20060316 20080521 20100728 20121115
20060317 20080522 20100729 20121130
20060318 20080523 20100730 20121218
Requirement is:
Based on start date: YYYYMMDD and end date in same format
to list out all of the dates including start and end in the whole range..
You can assume that the start and end dates are entered in this format.
The dates are actually directory names, and I need to go into each directory (in reverse date order) and issue a command while checking other certain conditions.
Any help would be appreciated!!
-Greg
Basically I need to wrap the following into a loop and continue processing date directories:
#!/bin/ksh
START=$1
END=$2
FILES=$3
TOT=0
EXCEED=20
## Get dates in the range??????
cd /a/archive/$DATE_CURR
stage *
## Find the number of active tape drives by user 900
ACTIVE_NUM=$(samcmd n|grep '900'|wc -l)
## Throttle if more than 3 tape drives in use by user 900
if [[ ${ACTIVE_NUM} -gt 3 ]]
then
echo "Users are busy"
exit
fi
## Find wait time of drives for user 900
# Get highest wait time of all drives
## WAIT=$(samcmd n|grep '900'|awk '{print $5}'|sed -e 's/\://g'|sort|tail -1)
TIME=$(samcmd n|grep '900'|awk '{print $5}'|sort|tail -1)
## echo ${TIME}
HOUR=$(echo ${TIME} | cut -f1 -d:)
## echo ${HOUR}
MIN=$(echo ${TIME} | cut -f2 -d:)
## echo ${MIN}
WAIT=$(echo "${HOUR} * 60 + ${MIN}"|bc)
## echo ${WAIT:-444}
# If wait time exceeds threshold, send email
if [[ ${WAIT} -gt ${EXCEED} ]]
then
MSG="$(printf "At least one tape drive has been waiting for ${WAIT} minu
tes\n\n")
$(samcmd n)"
## WAIT HERE ???
## Get number of files processing
for line in $(samcmd n | grep active | awk '{print $6}')
do
TOT=$(expr ${TOT} + ${line})
done
##printf "Total number of files: $TOT\n\n"
# Check if limit exceeded, if so, send email recording ending spot and exit
if [[ ${TOT} -gt ${FILES} ]]
then
echo "Staging Limit Exceeded"
samcmd n|mailx -s "Staging Limit Exceeded" email1@company.com,email2@company.com
exit
fi
And the Get dates in the range, is where I get stuck at...