script for comparing the times.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for comparing the times.
# 1  
Old 07-08-2009
script for comparing the times.

Hi,
My below output file looks like this.

Backup status at Tue Jul 7 03:30:07 EDT 2009 CMLP
Job Name Last Start Last End ST Run Pri/Xit
____________________________ ____________________ ____________________ __ _______ ___
tnx415uu 07/06/2009 22:01:41 ----- RU 5547800/1
tnp415uu 07/06/2009 22:01:58 07/06/2009 22:02:54 SU 5547800/1
toebafuu 07/06/2009 22:05:58 07/06/2009 22:29:32 SU 5547800/1
tosbafuu 07/07/2009 02:32:03 07/07/2009 02:32:25 SU 5547800/1
3xibafuu 07/07/2009 02:32:36 07/07/2009 02:34:25 SU 5547800/1
tnbbafuu 07/07/2009 02:34:35 ----- RU 5547800/1
3xdbafuu ----- ----- AC 5547800/0
tnu415uu ----- ----- AC 5547800/0

Job Name Last Start Last End ST Run Pri/Xit
____________________________ ____________________ ____________________ __ _______ ___
HP_nu_db_process 07/06/2009 22:00:08 07/07/2009 02:33:27 SU 1023852/1
HP_nu6003ud 07/07/2009 02:30:31 07/07/2009 02:31:44 SU 1023852/1
HP_nu6007ud 07/07/2009 02:32:45 07/07/2009 02:33:18 SU 1023852/1
HP_nu6001ud 07/06/2009 22:00:21 07/06/2009 22:00:32 SU 1023852/1
HP_nu6005ud 07/07/2009 02:30:14 07/07/2009 02:30:16 SU 1023852/1


i am generating the above out put for my backup jobs. Now i am checking manually for the validity of the bakup by comparing the times.

Now i am planning to write a shell script to check. first i need to check the todays date and time when the job has started for each and every line.
could any one help me in this how to write a shell script for this. I am a very beginner fot shell scripting.

Thanks in advance,
Raju
# 2  
Old 07-08-2009
Not sure how you want to "check" the data to make sure it is okay. So if you read everyline in the file and compare to todays date then what do you want to do?

For example:
testdate=`date +%m/%d/%Y`
grep "$testdate" $youroutputfile

will give you all lines with the current date where youroutputfile is the name of the file you created by your output. But what do you want to do with the output from the grep command?

Last edited by BubbaJoe; 07-08-2009 at 03:10 AM..
# 3  
Old 07-08-2009
Hi Thanks for the reply.
Please find the requiremtn below.

Backup status at Tue Jul 7 03:30:07 EDT 2009 CMLP

Job Name Last Start Last End ST Run Pri/Xit
____________________________ ____________________ ____________________ __ _______ ___

tnx415uu 07/06/2009 22:01:41 ----- RU 5547800/1
tnp415uu 07/06/2009 22:01:58 07/06/2009 22:02:54 SU 5547800/1
toebafuu 07/06/2009 22:05:58 07/06/2009 22:29:32 SU 5547800/1
tosbafuu 07/07/2009 02:32:03 07/07/2009 02:32:25 SU 5547800/1
3xibafuu 07/07/2009 02:32:36 07/07/2009 02:34:25 SU 5547800/1
tnbbafuu 07/07/2009 02:34:35 ----- RU 5547800/1
3xdbafuu ----- ----- AC 5547800/0
tnu415uu ----- ----- AC 5547800/0


Job Name Last Start Last End ST Run Pri/Xit
____________________________ ____________________ ____________________ __ _______ ___

HP_nu_db_process 07/06/2009 22:00:08 07/07/2009 02:33:27 SU 1023852/1
HP_nu6003ud 07/07/2009 02:30:31 07/07/2009 02:31:44 SU 1023852/1
HP_nu6007ud 07/07/2009 02:32:45 07/07/2009 02:33:18 SU 1023852/1
HP_nu6001ud 07/06/2009 22:00:21 07/06/2009 22:00:32 SU 1023852/1
HP_nu6005ud 07/07/2009 02:30:14 07/07/2009 02:30:16 SU 1023852/1



Hi Please find my requirement.

I will be delaring the variables and siignig the values. Below are the 8 values assigned to 8 variables.

1. HP_nu_db_process
2. HP_nu6001ud
3. tnx415uu
4. HP_nu6005ud
5. toebafuu
6. HP_nu6007ud
7. tosbafuu
8. HP_nu6003ud

now first i need to check the date and time of the first variable. the date has to be one day before. if it is true then i need to jump for the second variable and need to check the date and time.if it is true then i need to jump to third variable and check the date and time like this i need to check all the variables.
Please let me know if you dint understand.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Looping script several hundred times ?

Hi, I need to get a script to run over 100 of different files in a folder. The current input file is: (However the input file has to change by one counter each loop of the script(e.g. 001, 002, 003...)) 001.gif At the end of the scrip the current output is: 001output.gif It should... (4 Replies)
Discussion started by: pasc
4 Replies

2. Windows & DOS: Issues & Discussions

Schedule script is not executing some times

Dear Experts, Once again i need your vital help to fix my issue, please do the needfull. Issue:- I have schedule one script on windows server to run's every 10 min.(Script do check the alert log file,if database found down it send the email) While i'm doing the database down manually its... (12 Replies)
Discussion started by: Mohammed Fareed
12 Replies

3. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

4. UNIX for Dummies Questions & Answers

script help shell session times out

while read s1 ; do url= suf=ignore=.csv; wget $url$s1$suf; sleep 5; cat /home/joey/public_html/charts/program/fn\charts/data/tickers/header.txt > $s1.txt; chmod 777 $s1.txt; sed '1d' table.csv?s\=$s1 >> /home/joey/public_html/charts/program/charts/data/tickers/$s1.txt; rm -Rf... (0 Replies)
Discussion started by: harte
0 Replies

5. Shell Programming and Scripting

Counting script how many times it run?

i should use this script runs how many times before ? how can i do_? (3 Replies)
Discussion started by: utoptas
3 Replies

6. Shell Programming and Scripting

Shell script to run x times

Hi, First i need to cd to this directory $SWDIR/util Second i need to run the following either 4 times or 20 times ./swadm add_process 1 BG Y how can i put this in a script which should ask for user input on how many times you want to run this Thanks, (5 Replies)
Discussion started by: lookinginfo
5 Replies

7. UNIX for Dummies Questions & Answers

comparing two times

Hi Good Morning all, I have two dates and times in the beloe format. 1. 07/18/2009 03:45:49 2. 07/18/2009 03:46:41 i will grep these values from a file. Now my problem is i need to find out whether the second valus is bigger thatn the 1 value. How to compare the times. Please help me in... (4 Replies)
Discussion started by: intiraju
4 Replies

8. AIX

how would you know your server was rebooted 3 times or 5 times

Is there such location or command to know how many times did you reboot your server in that particular day?in AIX. (3 Replies)
Discussion started by: kenshinhimura
3 Replies

9. Shell Programming and Scripting

Awk script to add times.

Hey, Im trying to format the last command to tell me just the user names, logins, and the time that they were logged in. So far I got the users logins using a loop that counts the amount of times a user logged in but im not sure how to start the time array. The time im trying to use is the last... (2 Replies)
Discussion started by: Trilogie
2 Replies

10. Shell Programming and Scripting

Help script for login times

I am new to shellscript . PLease help me how can I write the following script. $ who ray pts/0 aug 31 01:18 ( 65.169.28.200 ) ray pts/1 sep 2 02:28 ( 65.169.28.200 ) bob pts/3 sep 2 02:31 ( 65.169.28.201 ) when run the command who |./ script , the script should... (3 Replies)
Discussion started by: LAY
3 Replies
Login or Register to Ask a Question