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.
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.
Are you sure you're looking at system time on the OS and not hardware time?
ASKER
I hope, i am looking at OS time by using "date" command .... How can i check Hardware time????
Thanks for any inputs...
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
ASKER
Please pardon my dumb question
From where Systemout log timestamp getting ?????
Why its drifting from Unix date command?
Thanks
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?
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());
}
}
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 ....
//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
ASKER
I am running that script ..... i let you know how it goes!!!
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
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
I think you can call that 'no drift' ;-)
That was what i expected
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
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!!!!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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?
ASKER
Without flag!!!!
Do you want me start JVM with "-XX:+UseGetTimeOfDay" as command line argument?
Do you want me start JVM with "-XX:+UseGetTimeOfDay" as command line argument?
Yes!!!!