Re: [Server-devel] timestamps on backups

2009-09-17 Thread Hamilton Chua
Thanks Tom and Martin,

I think I have figured it out. Sorry for any confusion. 

It seems the timestamps are correct on the server, it is only when
displayed in the backup page (dsbackup.php) where the times are off. For
example, a backup done just a few minutes ago would say it was done 4
hours ago on that page.

The problem is the timezone. When I specifically set the date.timezone
parameter in php.ini to UTC, the text started appearing correctly in the
backup page. So it seems PHP is using a different timezone.

/etc/sysconfig/clock says that the timezone of the system is
America/New York which is probably the timezone PHP is using.


On Wed, 2009-09-16 at 15:05 -0700, Tom Mitchell wrote:
 On Wed, Sep 16, 2009 at 5:37 AM, Martin Langhoff
 martin.langh...@gmail.com wrote:
  On Wed, Sep 16, 2009 at 2:28 PM, Hamilton Chua hamilton.c...@gmail.com 
  wrote:
  I'm not sure if anybody has noticed this yet but after doing a backup,
  it seems the datestamps on the backup page are wrong.
 
  We might need more detail than that if we're to understand the situation :-)
 
  Is there something about time zones and time synchronization that we
  need to be aware of with regards to backups.
 
  Yes, the utc time on all machines should make sense. So do
 
   date --utc
 
  on XS and on the laptops involved to make sure all players are in the
  same decade. This has been tested with machines on different TZs so it
  should work. As long as utc agrees across machines.
 
  --
   martin.langh...@gmail.com
  http://lists.laptop.org/listinfo/server-devel
 
 The two numbers 4 hours and 40 years are almost telling.
 
 Linux keeps time as seconds from midnight January 1, 1970 12:00:00 GMT.
 Today GMT (Greenwich Mean Time) has been replaced by UTS (Coordinated
 Universal Time)
 which is GMT done better with atomic clocks.
 
 Since you are using XS on 0.6d5 and Sugar on a Stick the system gets the
 initial time of day (date) from the local hardware clock.   A unix/Linux 
 system
 default sets the local hardware clock to UTS while windows sets it to
 local time.
 Depending on daylight savings time in (say) Oklahoma four hours looks
 like a Windows
 system setting the hardware time of day.  Since Linux can be configured to 
 play
 nice with windows and set the hardware clock to local time windows is not
 always the issue in possiblly confusing the offset from GMT/UTS.
 
 The 40 years is very close to the beginnig of unix time (zero seconds) and
 can be seen on a confused local time of day clock.
 
 NTP (network time protocol) tools can be used to set the time of
 day on a network connected system to the correct UTS time.
 
 Local time is computed based on UTS and an offset time zone.
 
 Since all binary time stamps are UTS different users can set different
 timezone values in their environment and the system will do the 'right' thing.
 
 See:
   date
   date --uts
   date -u
   (export TZ=Europe/Paris;date;date-u)
 #
  touch /tmp/now
  stat /tmp/now
  (export TZ=Europe/Paris; stat now)
 
 
 
 
 
 
 
 
 
 
 

___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


Re: [Server-devel] timestamps on backups

2009-09-17 Thread Martin Langhoff
On Thu, Sep 17, 2009 at 1:13 PM, Hamilton Chua hamilton.c...@gmail.com wrote:
 /etc/sysconfig/clock says that the timezone of the system is
 America/New York which is probably the timezone PHP is using.

That's weird. Questions

 - Can you confirm date --utc is correct on the XS and on the involved XOs?

 - If you look at the datastore-timestamp directories - are the
timestamps correctly in UTC?

 - If you run tzselect, change the tz to your local tz -- does it fix
the problem? If it does, is the problem fixed for new backups or for
all backups?

The PHP code in dsbackup.php should be ignoring timezones, but
something might be sneaking in. Also - the timestamp in the dirnames
may be wrong.


m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


Re: [Server-devel] timestamps on backups

2009-09-17 Thread Hamilton Chua
Hi Martin,

My responses inline ...

  - Can you confirm date --utc is correct on the XS and on the involved XOs?

Yes, date--utc on both XS and XO's are the same if not close to each
other, the difference being a few seconds.

  - If you look at the datastore-timestamp directories - are the
 timestamps correctly in UTC?

Yes, the directory name uses the UTC timestamp.

  - If you run tzselect, change the tz to your local tz -- does it fix
 the problem? If it does, is the problem fixed for new backups or for
 all backups?

The timezone of the system has always been the local tz.

 The PHP code in dsbackup.php should be ignoring timezones, but
 something might be sneaking in. Also - the timestamp in the dirnames
 may be wrong.

I checked the directory names and it seems they are correctly UTC. It
appears that the problem is just the calculation involved that returns
how long ago the backup was. It seems the time() function returns the
epoch based on the local timezone instead of the epoch based on UTC.

Best,

Ham



___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


Re: [Server-devel] timestamps on backups

2009-09-17 Thread Martin Langhoff
On Thu, Sep 17, 2009 at 1:55 PM, Hamilton Chua hamilton.c...@gmail.com wrote:
  - Can you confirm date --utc is correct on the XS and on the involved XOs?

 Yes, date--utc on both XS and XO's are the same if not close to each
 other, the difference being a few seconds.

thanks

 I checked the directory names and it seems they are correctly UTC.

Thanks!

 It seems the time() function returns the
 epoch based on the local timezone instead of the epoch based on UTC.

Actually - time() is doiing the right thing. It was the use of
mktime() that was bogus. Replace mktime() with gmmtime(), the 3 times
it appears in dsbackuplib.php and the problem is gone.

thanks for the debugging!



m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


Re: [Server-devel] timestamps on backups

2009-09-17 Thread Hamilton Chua

 Actually - time() is doiing the right thing. It was the use of
 mktime() that was bogus. Replace mktime() with gmmtime(), the 3 times
 it appears in dsbackuplib.php and the problem is gone.

Thanks Martin :-)

 thanks for the debugging!

You're welcome.


___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


[Server-devel] timestamps on backups

2009-09-16 Thread Hamilton Chua
Hello,

I'm not sure if anybody has noticed this yet but after doing a backup,
it seems the datestamps on the backup page are wrong. 

For instance, after a recent backup the backup page in moodle says that
the last backup was 4 hours ago even though monitoring the cron logs
show that it has just completed a backup.

Even weirder, moodle claims that some backups are 40 years old ! :-)

I am using XS on 0.6d5 and Sugar on a Stick.

Is there something about time zones and time synchronization that we
need to be aware of with regards to backups.

Thanks,

Hamilton



___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel


Re: [Server-devel] timestamps on backups

2009-09-16 Thread Tom Mitchell
On Wed, Sep 16, 2009 at 5:37 AM, Martin Langhoff
martin.langh...@gmail.com wrote:
 On Wed, Sep 16, 2009 at 2:28 PM, Hamilton Chua hamilton.c...@gmail.com 
 wrote:
 I'm not sure if anybody has noticed this yet but after doing a backup,
 it seems the datestamps on the backup page are wrong.

 We might need more detail than that if we're to understand the situation :-)

 Is there something about time zones and time synchronization that we
 need to be aware of with regards to backups.

 Yes, the utc time on all machines should make sense. So do

  date --utc

 on XS and on the laptops involved to make sure all players are in the
 same decade. This has been tested with machines on different TZs so it
 should work. As long as utc agrees across machines.

 --
  martin.langh...@gmail.com
 http://lists.laptop.org/listinfo/server-devel

The two numbers 4 hours and 40 years are almost telling.

Linux keeps time as seconds from midnight January 1, 1970 12:00:00 GMT.
Today GMT (Greenwich Mean Time) has been replaced by UTS (Coordinated
Universal Time)
which is GMT done better with atomic clocks.

Since you are using XS on 0.6d5 and Sugar on a Stick the system gets the
initial time of day (date) from the local hardware clock.   A unix/Linux system
default sets the local hardware clock to UTS while windows sets it to
local time.
Depending on daylight savings time in (say) Oklahoma four hours looks
like a Windows
system setting the hardware time of day.  Since Linux can be configured to play
nice with windows and set the hardware clock to local time windows is not
always the issue in possiblly confusing the offset from GMT/UTS.

The 40 years is very close to the beginnig of unix time (zero seconds) and
can be seen on a confused local time of day clock.

NTP (network time protocol) tools can be used to set the time of
day on a network connected system to the correct UTS time.

Local time is computed based on UTS and an offset time zone.

Since all binary time stamps are UTS different users can set different
timezone values in their environment and the system will do the 'right' thing.

See:
  date
  date --uts
  date -u
  (export TZ=Europe/Paris;date;date-u)
#
 touch /tmp/now
 stat /tmp/now
 (export TZ=Europe/Paris; stat now)











-- 
T o m   M i t c h e l l
mitch-at-niftyegg-dot-com
___
Server-devel mailing list
Server-devel@lists.laptop.org
http://lists.laptop.org/listinfo/server-devel