Need to get 4 Hrs back time and compare with successive time


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to get 4 Hrs back time and compare with successive time
# 1  
Old 07-15-2008
Need to get 4 Hrs back time and compare with successive time

Hi all,

I am working on a script in which i need to get 4 hrs back time from the current time which i got from this perl function :

`perl -e 'print localtime(time() - 14400) . "\n"'`

now i need to get this in a loop and increment that time by 15 minutes
i.e
i=900(=15minutes)
`perl -e 'print localtime(time() - 14400+$i) . "\n"'`
I do not know perl much and the above code does not work . i have to compare time from a table column from a database which has a listing afer every 15 minutes . so basically i hv to get a loop in which i can use this function and compare the time which is exactly after every 15 minutes. there is a new lisitng in the Db after every 15 minutes and i need to check the time gap.

How can I compare time from this perl function or if there is any other script it will be really appreciated .

Thanks,
Manik
# 2  
Old 07-15-2008
You have this: 'print localtime(time() - 14400+$i) . "\n"' which is a single-quoted string. It is stopping the shell from replacing $i with the value. You must move $i outside of the single quotes. So turn your single-quoted string into one single-quoted string, then $i, then another single-quoted string.



`perl -e 'print localtime(time() - 14400+'$i') . "\n"'`
# 3  
Old 07-15-2008
Thanks,
Its working . Really appreciate ur help

Last edited by maanik85; 07-15-2008 at 09:54 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. What is on Your Mind?

Well it took a bit of time but I am back on the road again...

I have not been very active on here for a while and when I have it was with CygWin... Well this MBP had to go back to the Apple Store for a new disk drive. It was repaired under warranty and I was very pleased with the service. However, returning this tub back to not quite the same as it was... (0 Replies)
Discussion started by: wisecracker
0 Replies

2. Shell Programming and Scripting

Compare Last Modified Time across Time Zone

Hi, I'm new to shell script programming, I only have Java programming background. I'm writing a shell script to do file synchronization between 2 machines that located at different time zone area. Both machine were set its time zone according to its geographical location (Eg: server is at... (1 Reply)
Discussion started by: python
1 Replies

3. SuSE

Time resetting to 00 HRS on starting

I Have a SUSE Linux Enterprise server 9.0. When I start the server , using date command I daily find that the time it is showing is 00.00 Hrs. It shows the date correctly. Every day I have to set the time using the date command. I am facing this proble from last 3 weeks but couldn't find a... (4 Replies)
Discussion started by: V.V.KUMAR
4 Replies

4. UNIX for Dummies Questions & Answers

Rolling back time

Hi all, Have a small problem. Back in October the pervious sys-admin (of a client's company) made the necessary adjustments to the system clock for daylight savings (Sydney time - +11 GMT). As far as I can gather, they just amended the time - NO TIMEZONE !?! Is there an effective and safe... (5 Replies)
Discussion started by: Cameron
5 Replies
Login or Register to Ask a Question