- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Wrong strftime time zone
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2009 05:41 AM
11-26-2009 05:41 AM
The plan is to add timestamps to command history entries on HP-UX 11.23 ia64 machines for non-root users by changing the default shell to bash and exporting appropriate HISTTIMEFORMAT in /etc/profile. Everything went fine until I had to set HISTTIMEFORMAT. Everything I tried gave me the wrong time. After fannying around a bit I found out that strftime somehow lives in a different time zone, because my timestamps were off by exactly 7 hours, and %Z returned EST (east coast US, I believe), not EET (Eastern European time), which is the correct one. The sum of this difference is 7 hours (UTC+2 for EET and UTC-5 for EST). The 'echo $TZ' returns EET-2EETDST as it should be. Where does strftime get that I should be shown time in the US, not the local time?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2009 07:51 AM
11-26-2009 07:51 AM
Solutiontzset() Sets the values of the external variables timezone,
daylight, and tzname according to the contents of
the TZ environment variable (independent of any time
value). The functions localtime(), mktime(),
ctime(), asctime(), and strftime() (see
strftime(3C)) call tzset() and use the values
returned in the external variables described below
for their operations. tzset() can also be called
directly by the user.
When the environment variable TZ is not set, tzset()
checks the default file /etc/default/tz for the
timezone value and sets timezone values based on
that. The file /etc/default/tz contains the
timezone value used by tzset() when the environment
variable TZ is not set. The format for the file is
same as TZ format without the prefix TZ=. Please
check environ(5) for TZ format. The order of TZ
setting is as follows.
1) if the environment variable TZ is present, it
takes precedence.
2) if TZ is not present, then the value contained in
/etc/default/tz is used for the default.
ctime(3C) ctime(3C)
3) if /etc/default/tz is not set then the default
value is equivalent to EST5EDT (Eastern Standard
Time) of the USA.
What do you have in /etc/default/tz? I would always match /etc/TIMEZONE (called by login profiles) and /etc/default/tz (called by library functions) to avoid confusing results.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2009 12:32 PM
11-26-2009 12:32 PM
Re: Wrong strftime time zone
Are you sure you have exported TZ?
Have you exported it BEFORE you invoke bash?
I.e. bash may only check the values of env vars when it starts, not the separate set of variables that's part of the user environment.
(At least that's how a real shell works.)
You may have to have bash exec itself in its .profile.
If your machine only works in one timezone, then as Bill mentioned, setting /etc/default/tz /etc/TIMEZONE may help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2009 10:50 PM
11-26-2009 10:50 PM
Re: Wrong strftime time zone
Regarding what Dennis said - if I understood You correctly, I believe that $TZ is always exported and has the correct value in both the root shell (sh) and user shell (bash). The /etc/TIMEZONE has the correct TZ set and exportet in it.
Regarding Bill's comment - I checked /etc/defaults/tz, and it had the EST set in it. I changed it to EET-2EETDST and now strftime displays the time correctly. Strange somehow that it was not the $TZ strftime based its time zone on, although it was exported and available. Anyway, the problem is solved now. Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2009 11:47 PM
11-26-2009 11:47 PM
Re: Wrong strftime time zone
As I said, TZ must be exported BEFORE bash starts. Which is near impossible for a login shell.