Sponsored Content
Full Discussion: CurrentTime-4 hours
Top Forums Shell Programming and Scripting CurrentTime-4 hours Post 302547099 by rajubollas on Sunday 14th of August 2011 12:49:13 AM
Old 08-14-2011
Thanks for the Help,
Still i am looking for IF then Else part.

Code:
JobStat=`dsjob -report $Project $i | grep status | awk -F= ' { print $2; } ' | awk ' { print $1; } '`;
if [ "$SysDate" == "$JobRunDate" ] && [ "$JobStTime" -ge "$CurSysHrs" ] && [ [ "x3" >= "x${JobStat}" ] || [ "x0" != "x${JobStat}" ] || [ "x2" != "x${JobStat}" ] ] 
then
{
echo "$JobName,$StartTime,$EndTime,$JobStat" >>$Jobstatus
}
fi

---------- Post updated at 10:19 AM ---------- Previous update was at 08:55 AM ----------

Thanks for the response.
But here i have to compare output numbers coming from two different time variables.
My question is i have to go 4 hours back from current time all the time in day(24hrs) and trying to capture the result list of jobs those executed in last four hours.

Pleae see entire code:

Code:
 
#!/usr/bin/sh
#Scripted by Raju B on Aug062011#
#Datastge Jobs monitoring script
cd /QIS2FTP/scripts/Scripts
#Removing Last Run Jobstatus.txt file.
rm /QIS2FTP/scripts/Scripts/Jobstatus.txt
#Printing Output in Jobstatus.txt
Jobstatus=/QIS2FTP/scripts/Scripts/Jobstatus.txt
echo "JobName,StartDateTime,EndDateTime,Status " >>$Jobstatus
echo "------------------------------------------------------------" >>$Jobstatus
#set -x
# import my environment
. /QIS2FTP/dsclientprod/home/my.env
#Variables declaration
#List of all jobs in DS QIS2 Project
DSJoblist=`dssearch -ljobs -matches -sub -oc QIS2 * |cut -f2 -d'\'|awk '{print $1}'`
Project=QIS2
SysDate=`date +%Y%m%d`
 
for i in $DSJoblist
do
#DSJobStatus variable for collecting Job start and End time,Job duration and Job status
DSJobStatus=`dsjob -report $Project $i 2> /dev/null | grep "Job" | cut -f2 -d'='`
StartTime=`echo $DSJobStatus | cut -f1,2 -d' '`
EndTime=`echo $DSJobStatus | cut -f3,4 -d' '`
JobStat=`dsjob -report $Project $i | grep status | awk -F= ' { print $2; } ' | awk ' { print $1; } '`;
JobName=`dssearch -ljobs -matches -sub -oc QIS2 $i`
#Dateformat 20110805
JobRunDate=`echo $StartTime |awk '{print $1}'|sed 's/-//'|sed 's/-//'`
#Time in hours ex: 09
JobTimeH=`echo $StartTime |awk '{print $2}'|cut -f1 -d':'`
JobTimeM=`echo $StartTime |awk '{print $2}'|cut -f2 -d':'`
JobStTime=`echo "$JobTimeH$JobTimeM"`
#Going 4 hour back from local time zone EST.
CurSysHrs=`TZ=GTM+1:00 date '+%H%M'`
#echo "Print Current time before 4 hours $CurSysHrs"
if [ "$SysDate" == "$JobRunDate" ] && [ "$CurSysHrs" -ge "$JobStTime" ]
then
if [ "x1" == "x${JobStat}" ]
then
echo "$JobName,$StartTime,$EndTime,$JobStat" >>$Jobstatus
fi
fi
# if [ "$SysDate" == "$JobRunDate" ] && [ "$CurSysHrs" -ge "$JobStTime" ]
# then if [ "x0" != "x${JobStat}" ]
# then 
# echo "$JobName,$StartTime,$EndTime,$JobStat" >>$Jobstatus
# 
# fi 
# fi
# if [ "$SysDate" == "$JobRunDate" ] && [ "$CurSysHrs" -ge "$JobStTime" ]
# then if [ "x2" != "x${JobStat}" ]
# then 
# echo "$JobName,$StartTime,$EndTime,$JobStat" >>$Jobstatus 
# fi 
# fi
done
#set +


Last edited by zxmaus; 08-14-2011 at 01:55 AM.. Reason: PSIC_FACT_CLAIM changed * for all jobs
 

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Have we just had a rollback of a few hours?

Have we just had a rollback of a few hours? (1 Reply)
Discussion started by: porter
1 Replies

2. SCO

System restarting itself every after 20-24 hours

HI We have Compaq ML350 G2 server with UNIX SCO 5.0.5 OS , can anyone help us to get rid about the system restarting problem by itself every after2-24 hours with following error " MEMORY CORE DUMP " . Waiting for your ASAP help. Thank You . (4 Replies)
Discussion started by: munirh
4 Replies

3. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

4. What is on Your Mind?

How Many hours on Computer?

How many hours you spend on Computer in a day??? (10 Replies)
Discussion started by: malcomex999
10 Replies

5. AIX

cron off by 5 hours

stupid question im sure, but its frustrating My cron jobs are off by 5 hours. My system time is right but all of my cron jobs are running approximately 5 hours late. Any idea why? (4 Replies)
Discussion started by: mshilling
4 Replies

6. Shell Programming and Scripting

ps -ef |grep 24 hours

I need to grep PIDs older than 24 hours (1 day) or more. ps -ef |grep ??? Please advise. (10 Replies)
Discussion started by: Daniel Gate
10 Replies

7. Shell Programming and Scripting

Exit script after exactly 3 hours

Need to run a script for exactly 3 hours. It will have while loop which is to keep running until its 3 hours since the script's invocation time and then exit the script. Script could be invoked at any time. May have to change the number of hours later as per need. Are there any existing... (5 Replies)
Discussion started by: Prev
5 Replies

8. Shell Programming and Scripting

Need help looking for missing hours.

I have a file that should cover a days worth of stats, at the beginning of each 15 minute report I have a unique header that looks like the below example. The "0000" and "0015" will change in the header line to show which 15 Minute interval the report is covering and of course from day to day the... (7 Replies)
Discussion started by: fsanchez
7 Replies

9. Shell Programming and Scripting

Get the no of hours between days

Hi, i have a date 1- 2013101511 date2 -2013101812 need toget the no of hours between them,can any one tellme the logic. (6 Replies)
Discussion started by: sandeep karna
6 Replies
All times are GMT -4. The time now is 03:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy