NOTE: If you are setting a timezone during your server setups then STOP IT! A good system administrator will set the system time to UTC, which does NOT observe time changes for DST.
I've seen developers write programs to verify daylight and standard time changes. They naively write the program to print the current time, delay a few seconds, then print the current time again and they configure it to run at a few seconds before the date and time of time change. This is wasted effort. A Unix system does not change it's system clock at the point of time change. A basic understanding of how Unix manages it's time will clear up these misunderstandings and allow you to write a program to run at anytime to verify the date and time of daylight and standard time changes.
Unix keeps track of time in seconds. It is an unsigned value, 32 bits in size. All Unix systems that are 32-bit architecture will need to be patched before the year 2038. This is the year when the 32-bit seconds counter will overflow. If you're running Unix on a 64-bit architecture, you're immune. All Unix (and Linux) systems track time in seconds since Epoch, which was Jan. 1, 1970 GMT. This can be demonstrated with the following:
deb01:~# date '+%s'
1225028445
deb01:~#
The date command is a Unix and Linux utility that allows us to query current time as well as formatting it and doing time calculations. The above "date" example will retrieve the current time and print it in seconds. Running the date command without any arguments will return the current date and time. For example:
deb01:~# date
Sun Oct 26 09:28:22 EDT 2008
deb01:~#
Notice that we get the date and time in string format and our current timezone setting. Be aware that the date command is sensitive to the setting of your shell environment variable TZ. The date command also allows us to perform time translations using the time from a fixed string. Take for example:
deb01:~# date --date="Nov 2 2008 01:59:59" "+%s"
1225605599
deb01:~#
The above command indicates that we want the seconds returned (as indicated by the "+%s" argument), but we've also established a base time reference by using the --date argument. We set the base time reference to "Nov 2 2008 01:59:59", one second before the time of EDT to EST change. Now if I merely increment the seconds value returned from the above date command, the "1225605599", then the seconds value would reference exactly 02:00:00, or we would expect. But instead, since this is the switchover time from EDT to EST, we will see the new time of 01:00:00. Unix uses separate libraries to perform timezone changes. These timezone packages will identify DT and ST change dates and times all across the world. It's these timezone libraries that merely translate the Unix seconds counter into the form we expect for the given timezone we are in. The Unix library call, strftime, can be used to perform my translation of Unix seconds into a human readable date and time string. This library is available in awk as well as perl and many other script interpreters.
Also be aware that most Linux systems will initially set their clock (seconds) based on the setting of the hardware clock in bios. I've seen many administrators set the bios clock to their locale timezone. Bad move! If you examine hardware logs from bios, they will be time-stamped based on the bios clock. Bios clocks DO NOT compensate for the daylight savings time switch. You should ALWAYS set the bios clock to UTC or GMT time. The UTC/GMT timezones do not recognize daylight savings time. Note that EPOCH has always been Jan 1, 1970 GMT. Unix also runs a time synchronization protocol called NTP. All NTP time is based on UTC/GMT. So by setting bios to UTC, and Unix system time to UTC, you won't see those weird time jumps indicated in the console log when Linux starts up. As well, you'll have the clocks closly in-sync for when the NTP daemon starts. So your kernel boot times, bios logs and Linux log timestamps will be in-sync. If the systems that you manage are global, save yourself headaches by setting all systems to UTC. This way when theres some global network outage, you don't have to time-translate the timestamps on the remote systems, everything will be on the same time base. User's may set their TZ variable in the shell startup files to get locale specific time.
I have provided a very simple bash script that will display the DT to ST time change. You can add your own code to possibly change the setting of the TZ variable, or check the ST to DT time change.
#! /bin/bash
# vi:set nu ai ap smd showmatch tabstop=4 shiftwidth=4:
# Name: tz_check
# Date: Sun Oct 26 09:12:54 EDT 2008
# Author: Tom Sandholm
# Description: Script to confirm timezone standard and
# daylight time changes
########### main #####################
# get the seconds value for the DT to ST change date and time
DT2ST=$(date --date="Nov 2 2008 01:59:59" "+%s")
# run awk script to call libc function strftime to print
# the time. This will use the current TZ settings of
# the calling user. We print result to stdout for visual
# verification.
echo $DT2ST | gawk '\
{
now = $0
mesg = strftime("%m/%d/%Y %H:%M:%S", now)
print mesg
}'
# increment seconds
(( DT2ST++ ))
# call strftime again to print the ST time.
echo $DT2ST | gawk '\
{
now = $0
mesg = strftime("%m/%d/%Y %H:%M:%S", now)
print mesg
}'
# all done
exit 0