Link to home
Start Free TrialLog in
Avatar of pigeon5566
pigeon5566

asked on

Regarding TZ variable

1. what are the possible values in TZ variable in HP UNIX system.  what is it purpose and what is the format for changing it?

2. When i did a echo $TZ in the HP unix system i am getting EST5EDT.   when i run the date command  it's showing "06/22/2006.....EDT" .  Daylight saving begins on april and ends in oct t. If i do a date command  before april or after october will the time show as "02/22/2006.....EST". or " 02/22/2006.....EDT" .  Also in another HP Unix system if i did a echo $TZ it shows "CST0" what does it mean in this case, does it include daylight saving time?

3. From 2007  Clocks will be set ahead one hour on the second Sunday of March instead of the current first Sunday of April. We are using HPUX 10.2. since HP is not giving patches and we are not doing upgrade of the OS, we are planning to change the unix system time manually when march comes.  If we change the system time of the OS are we changing the GMT time of the system?

4. For the 3rd question, we are changing the system time only but how does unix system  knows that daylight saving begins only in month of April and not in March. Is there any way of doing it. If we change TZ will it become ok? If yes, how do we change the TZ?

 In the code when we call C library time functions and populate the tm structure. Provided the tm structure below
struct tm {
    int tm_sec;        seconds after the minute (from 0)
    int tm_min;        minutes after the hour (from 0)
    int tm_hour;       hour of the day (from 0)
    int tm_mday;       day of the month (from 1)
    int tm_mon;        month of the year (from 0)
    int tm_year;       years since 1900 (from 0)
    int tm_wday;       days since Sunday (from 0)
    int tm_yday;       day of the year (from 0)
    int tm_isdst;      Daylight Saving Time flag
    };

The tm_isdst flag will denote  a positive value if Daylight Saving Time is in effect.   The program might use this flag and do some processing. I think this flag will  not be set in March because of our UNIX system will know that April only daylight begins and will set it only in the april month.   If the unix system time  is changed this flag will not get updated. will this create an problem in the program.  Hope i am correct?    Is there any way to overcome this?


5. How do i change the unix system manually?



ASKER CERTIFIED SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland 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 pigeon5566
pigeon5566

ASKER

Thanks a lot for the info.
1.  When i did a ll i am gettting the below output. Which user can modify this one since i don't see a write permission or is there any command that can be given to be modified.
ll /usr/lib/tztab  
-r--r--r--   1 bin        bin           9376 Mar  9  1998 /usr/lib/tztab

2. If the above file is able to be changed, is it fine?  After modifying the file, do i  need to change the UNIX system time to reflect the daylight saving ?   My assumptions all the HP-Unix machines are running GMT Time  and the HP patches will change this file alone not the unix time. Pls correct me if am wrong. Anything else i need to do?

3. If the above file is able to be changed, should i change TZ environmental variable also?

4. We are assuming we need to change the unix system time and everything will be fine? Is it correct.


 

1) Only root can modify this file, as the "bin" user isn't used for logins; When saving it after modifying it with, e.g. vi, use :w!  
   (The ! overrides the read-only attribute for the file)

2) If you've looked at the file, you will see there are a number of sections for different timezones and the known rules for time changes. I can't remember exactly how it works but so long as you modify the file at least an hour in advance (e.g. for testing) the change gets picked up automatically when a user or process checks the time.  You just modify the section for the TZ the system is set to.

3) EST5EDT allows for daylight savings; I don't think CST0 does. You can change your own TZ variable and see what the effect is - it doesn't actually change the system clock, just what is reported by commands.

4) Again, this should not be necessary.
1. Before/after modifying this tztab file,  should i restart the application or cron or any reboot is required?

2.  Also in the config file i am able to entries like this
0 3 1-7 4 1987-2038 0 PDT7
0 1 25-31 10 1975-2038 0 PST8
Since daylight changes at 2:00 am at april, why they had put an entry for 3 am. Also in october the daylight time reverts back at 2:00 am. why there is an entry saying 1 am.


It's confusing, I know - Here's an extract from a document I wrote some years back:
---------------------------------------
The actual date and time of the time change is defined in /usr/lib/tztab. This file is used by Unix to determine the local deviation from the TIMEZONE. See `man tztab` for more information.

Fields are:

Min      Hr      D-O-M            Month      Year      D-O-W            Deviation
0       1       25-31              10           2002      6               GMT0

The above example will set the clock back to 01:00 GMT at 01:59 on Saturday 26/10/02

Note that days of the week commence with 0 for Sunday (as in crontab files). The Day of Month, Year and Day of Week fields can contain a range (numbers separated by hyphens) to make them usable over more than just the current year, but remember that actual dates for the BST change vary and that BST itself may not be used indefinitely. Note also that one of D-O-M and D-O-W must be a range, or HP-UX will ignore it
---------------------------------------

I can't remember how the "spring forward" rule actually works; The above was based on lots of experimenting!

I would ensure that applications like databases are shut down before the selected time change, as logfile entries will be wrong; In fall, the applications should not be restarted until at least one hour after the time change to avoid duplicate log entries and potential data corruption
1. You had said "The above example will set the clock back to 01:00 GMT at 01:59 on Saturday 26/10/02"  
Min     Hr     D-O-M          Month     Year     D-O-W          Deviation
0      1      25-31            10          2002      6             GMT0
"

Where is that 1:59 is mentioned in the above entry. How does Unix know to change at 01:59?
I searched man tztab i am unable to find that one.

2.  We are using Informix database.  Does the database takes time from unix system time?
Is it enought  if we change  tztab.

3. Do we need to restart the application if i not bothered about duplicate log entries? Is it sufficient if we can restart the cron alone?












Avatar of Arty K
pigeon5566, I'm not sure about HP-UX. Try to read following manuals.

1)
man zic
man tzset
man tzfile

2) I don't know exactly. If it uses UNIX timestamps or UTC time, it's not dependant on TZ, if it doesn't, it's probably dependand.

3) You don't need to restart applications or cron daemon.
I am planning to  try this in testing machine to verify whether tztab works?  We can modify the tztab file ,change the sys time to march 2007 and run some date command, local time C function. Will it work?