Link to home
Start Free TrialLog in
Avatar of wasuser
wasuser

asked on

JVM time drifting

HP_UX OS time varies from Websphere systemout log.

 Why OS time(date) different from systemout log.

When i restart servers, its getting OS time. However, its drifting 2 minutes after one day... I greatly appreciate anyone inputs.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you sure you're looking at system time on the OS and not hardware time?
Avatar of wasuser
wasuser

ASKER

I hope, i am looking at OS time by using "date" command .... How can i check Hardware time????

Thanks for any inputs...
Yes, you would be. I've never come across this before. I would check to see if you can reproduce it in *any* java program
Avatar of wasuser

ASKER

Please pardon my dumb question

From where Systemout log timestamp getting ?????

Why its drifting from Unix date command?

Thanks


Java's meant to get it from the system. How far does it differ right now?
Avatar of wasuser

ASKER

3 minutes after 40 hours ....
That could be due to threading issues. The time may be got but unable to print immediately. Run the following and tell me what the difference is:
public class DatePrinter {
    public static void main(String[] args) {
        System.out.println(new java.util.Date());
    }
}

Open in new window

Avatar of wasuser

ASKER

When i use follwoing TimeTest class:

//TimeTest.java
import java.util.Date;
public class TimeTest
{
    public static void main(String[] args)
    {
        System.out.println(new Date());
    }
}

RESULTS:
-----------
Wed Apr 09 12:45:58 EDT 2008

Date command results as follows:
Wed Apr  9 12:46:01 2008

When i start Application servers .... i am getting same time as OS time (date) .... However, if it is runs for 2 days then we can see 3 minutes drifting .... I am guessing May be JVM calculte time with CPU clicks ....

You could try the following and see if that delta grows
while [ true ];do date >>/tmp/clock.log;java TimeTest >>/tmp/clock.log;sleep $((60 * 30));done

Open in new window

Avatar of wasuser

ASKER

I am running that script ..... i let you know how it goes!!!
Avatar of wasuser

ASKER

Out put of that script:

Wed Apr  9 13:27:02 2008
Wed Apr 09 13:27:02 EDT 2008
Wed Apr  9 13:57:05 2008
Wed Apr 09 13:57:05 EDT 2008
Wed Apr  9 14:27:08 2008
Wed Apr 09 14:27:08 EDT 2008
Wed Apr  9 14:57:10 2008
Wed Apr 09 14:57:11 EDT 2008

see 1 second drifted for 1:30 hour

Thanks

>>see 1 second drifted for 1:30 hour

I think you can call that 'no drift' ;-)

That was what i expected
Avatar of wasuser

ASKER

I didn't get you ... However, why we are getting 1 second diffence ?
1 second is by no means surprising, especially since the two different 'programs' run serially
Avatar of wasuser

ASKER

OK ... i will let it run and see how it goes!!!

While googling, i found follwoing link ... in Reply 17 someone mentioned some patches .... Do you have any idea what are those ....????

http://forum.java.sun.com/thread.jspa?threadID=765165&start=15&tstart=0

Thank you very much!!!!
ASKER CERTIFIED SOLUTION
Avatar of Brian Utterback
Brian Utterback
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wasuser

ASKER

OK ...

1. When i restart my Application servers .. OS time match with Systemout logs ....
2.  After one day ...  difference between my OS time (running on HP-UX) and JVM time (represented by my app servers) is around 2 minutes...

Thanks in advance
Was that last comment with out without the suggested flag?
Avatar of wasuser

ASKER

Without flag!!!!

Do you want me start JVM with "-XX:+UseGetTimeOfDay" as command line argument?