The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Server Time Function Bug

Discussion in 'General Discussion' started by s_2_s, May 9, 2005.

  1. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    i noticed that bug
    i went to whm of root and changed the time zone using the server time function to another time zone
    then i sync. with time server

    now the new time zone and date[time] are so accurate
    but when i crea a simple php script to echo the date function it returns another time which is matching the old time zone and not the new accurate time zone
    however if i call that script using shell it returns the accurate time zone
    i believe it could be a bug or something
    here is a detailed example

    i made a sample php script that returns the date function and i called it by shell

    when i called the same script using any web browser on any computer [ local time zone has no effect ] it returns

    so why the 5 hours early in php scripts ????
    this also delay alot of important cron scripts and causing troubles

    please help !
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Since the discrepancy is through apache, have you tried restarting httpd? Changing the servers time can cause quite a lot of problems, another favourite is crond which you should always restart otherwise you'll have some odd times for your cron job runs.
     
  3. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    Thanks for your interest in helping me
    YES we are suffering server cron tasks issues
    and YES we have restarted cpanel , httpd many times and no change
    the reason we would say it could be abug is that the whm "server time" function should accordingly update the time zone everwhere else so cron and php [or apache ] can realize the new time zone or date change
    thanks alot
    waiting for more help
     
  4. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    anybody would help please ?
     
  5. AndyReed

    AndyReed Well-Known Member
    PartnerNOC

    Joined:
    May 29, 2004
    Messages:
    2,222
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Minneapolis, MN
    SSH to your server and run this command:
    hwclock --systohc
    This should synchronise the hardware and software clocks.

    Are you using NTP on your server?

    Now, rdate uses port 37, you need set the firewall to allow output on port 37 or rdate will timeout.

    If you're using ntpd, you'll need to configure APF Firewall UPD port for 123 for this to work(inbound/outbond.)
     
  6. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    thanks for your help
    i'm sorry but i didn't solve my problem
    i opend UDP PORts in apf "123" and also TCP port "37"
    then i restarted apf and once again synced the date using rdate then
    i ran the hwclock --systohc
    but when i call the php script using browser it gives the same old time zone date which is about 7 hours earlier
    and still experiencing problems with crond jobs they are running according to the old timing however stats are running at the correct time zone
    kindly provide me with more info. regarding this
    thanks you
     
  7. Rusky

    Rusky Member

    Joined:
    Nov 19, 2003
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    You are in a dedicated or in a VPS?

    I think that in a VPS the problem can't be solved because the server clock is not changed.

    Regards.

    Rusky
     
  8. AndyReed

    AndyReed Well-Known Member
    PartnerNOC

    Joined:
    May 29, 2004
    Messages:
    2,222
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Minneapolis, MN
    You might want to stop your server clock from drifting. Typically, every server using standard clock, over time your clock will drift. There is no clock is perfect per se, however the issues with motherboard timing, and so on, can cause your system clock to run a little fast.

    Let's say your server clock runs a little fast, gaining a quarter-second every hour. That won't matter for many people. You'll adjust the time the time every hour, who cares!

    Now, imagine a software that requires events to occur in sequence. Lets say the software bases that sequence on timestamps. Now, when your clock is "reset" to the right time, the clock moves backwards. The software thinks it is a quarter second earlier than it used to be, and the ordering of events gets screwed up. This could have very minor effects, or the program could fail. People may have experienced crashes or frozen programs due to this and never known why.

    Most programs including apache and proftpd aren't affected by the sudden change of time/clock. But other servers with games, possibly shoutcast and other streaming media servers are affected and need an accurate clock to run smoothly.

    The reason for asking if you are using NTP or Perldork (standard/conventional clock) on your server, is the fact that "ntpd" program constantly runs in the background and, instead of setting your clock once an hour, constantly corrects for your natural clock drift. Therefore, your server time/clock is accurate and there is never any moment when the clock might "snap back" to an older value.

    This is the advantage of running ntpd instead of ntpdate or rdate, knowing that your system is always accurate to within 3-4 milliseconds.

    To properly use NTP, you need to have the full set of NTP tools. You may already have them
    installed; you can check by running the following as root:

    rpm -q ntp

    BTW
    NTP is a protocol designed to synchronize the clocks of computers over a network. For more information go to: www.ntp.org

    Download and install NTP at: http://ntp.isc.org/bin/view/Main/SoftwareDownloads
     
    #8 AndyReed, May 11, 2005
    Last edited: May 11, 2005
  9. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello Rusky
    i do have a DEDICATED server
    Hello Andy
    thanks again for your contribution
    the software is already installed
    ntp-4.1.2-4.EL3.1
    on this server i'm running CENTOS 3.4
    how i got other servers with RH9 & Fedora and i dont see this problem there at all
     
  10. AndyReed

    AndyReed Well-Known Member
    PartnerNOC

    Joined:
    May 29, 2004
    Messages:
    2,222
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Minneapolis, MN
    Very good question; Every system is unique. This is how I see it.
     
Loading...

Share This Page