Solved

Regarding TZ variable

Posted on 2006-06-25
8
7,385 Views
Last Modified: 2013-12-06
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?



0
Comment
Question by:pigeon5566
  • 4
  • 3
8 Comments
 
LVL 20

Accepted Solution

by:
tfewster earned 50 total points
Comment Utility
1) `man 5 environ` - Look for the TZ environment variable
2) ditto
3) `man tztab` - It's easy enough to modify without needing a patch from HP
4) See both of the above
5) `man date `
0
 

Author Comment

by:pigeon5566
Comment Utility
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.


 

0
 
LVL 20

Expert Comment

by:tfewster
Comment Utility
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.
0
 

Author Comment

by:pigeon5566
Comment Utility
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.


0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 20

Expert Comment

by:tfewster
Comment Utility
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
0
 

Author Comment

by:pigeon5566
Comment Utility
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?












0
 
LVL 27

Expert Comment

by:Nopius
Comment Utility
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.
0
 

Author Comment

by:pigeon5566
Comment Utility
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?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now