Hi,
I need some help... i mean can someone give some idea on how to implement what i want to do...
I have script called Mail.ksh which calls another script called read.ksh. read.ksh appends data to time.out file...This Mail.ksh runs everyday say 9:00AM on cron... We have like 50 Jobs on cron and read.ksh collects data form these 50 jobs and appends the data to time.out
time.out file looks like this
.
.
.
.
20090123,00:02:33,00:00:35,8134,00:01:42,00:01:32,02:02:08,321055,
20090124,00:02:33,00:00:35,9345,00:01:42,00:01:32,02:02:08,321055,
20090125,00:02:33,00:00:35,8783,00:01:42,00:01:32,02:02:08,321055,
20090126,00:02:33,00:00:35,44554,00:01:42,00:01:32,02:02:08,321055,
The mail.ksh calculates the current mantaince date using the below code
julian2date() # julianday
{
typeset -i day month year tmpday
julianday=$1
((tmpday = julianday - 1721119))
((centuries = (4 * tmpday - 1) / 146097))
((tmpday += centuries - centuries/4))
((year = (4 * tmpday - 1) / 1461))
((tmpday -= (1461 * year) / 4))
((month = (10 * tmpday - 5) / 306))
((day = tmpday - (306 * month + 5) / 10))
((month += 2))
((year += month/12))
((month = month % 12 + 1))
MONTH_LEN=$(echo ${month} | awk '{print length($1)}')
if [[ ${MONTH_LEN} = 1 ]]
then
format_month="0${month}"
else
format_month=${month}
fi
DAY_LEN=$(echo ${day} | awk '{print length($1)}')
if [[ ${DAY_LEN} = 1 ]]
then
format_day="0${day}"
else
format_day=${day}
fi
print $year$format_month$format_day
}
########################################################
# Get the Julian equivalent of the current date, subtract 1 day, convert back to a date
typeset -i LSD_DAY LSD_MONTH LSD_YEAR LSD_JUL CMD_JUL CUR_MAINT_DATE
YYYYMMDD=`date +%Y%m%d`
LSD_DAY=$(echo ${YYYYMMDD} | awk '{print substr($1,7,2)}')
LSD_MONTH=$(echo ${YYYYMMDD} | awk '{print substr($1,5,2)}')
LSD_YEAR=$(echo ${YYYYMMDD} | awk '{print substr($1,1,4)}')
LSD_JUL=$(date2julian ${LSD_DAY} ${LSD_MONTH} ${LSD_YEAR})
(( CMD_JUL = LSD_JUL - 1 ))
CUR_MAINT_DATE=$(julian2date ${CMD_JUL})
Usually the date will be previous daye ie if mail.ksh script is running at 9:00AM on 2009 01 27 then current mantaince date will be 2009 01 26
This is what the above code do.. The Mail.ksh takes the current maint date and pass it to read.ksh when will go a folder where the data of the files generated on current maint date are stored and collect the required data form them and appends the collected data to time.out
Now i want to change this... When ever mail.ksh runs it not only do the process for current maint date but also go back two dats and gets data...
like if its running on 27 then its also runs for data 26 and 25
get the data and place the data in the time.out such a way that it removes previous data and addes this data in the respective dates...
I want it to run 2 days back and remove data in time.out to respective date and place what so ever new data...
Please help me how to approch this problem...
Thanks a lot
-Bhagya