- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script using TZ variable
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-06-2006 06:39 AM
11-06-2006 06:39 AM
Script using TZ variable
I had a script which uses "TZ" variable in order to backdate and check the condition of the backup status and then delete the dump from Disk. After the recent TZ zones the script errors out as there is chaneg in "TZ" variable.
Before DST Changes:
TZ = MET
After DST Changes:
TZ = MET-1METDST
Can some one help me in to backdate the script using the new TZ varaiable.
FYI, In my script in oredr to backdate i was using.
TZ_OLD="$TZ+24"
TIA,
Vishwanath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 06:45 AM
11-06-2006 06:45 AM
Re: Script using TZ variable
The use of the following is commonly seen to compute tomorrow's date:
# TZ=GMT-24 date +%m/%d/%y
...and correspondingly, yesterdays's date:
# TZ=GMT+24 date +%m/%d/%y
Eurpopeans,living around the Prime Meridian are the "lucky" ones who can use +-24 hours to exactly compute yesterday or tommorrow *including* the correct time.
As noted by the man pages for 'environ(5)', the offset is the value that must be added to local time to arrive at UTC (GMT). The offset takes the format hh[:mm[:ss]] where 'hh' is any value from 0 through 23. The optional minutes (mm) and seconds (ss) fields are a value from 0 through 59. The hour field is required. If offset is preceded by a -, the time zone is east of the Prime Meridian. A + preceding offset indicates that the time is one that is west of the Prime Meridian.
Thus, you should beware when trying to perform such trickery as you describe.
A rigorous, safe method to find the day as it was 24-hours ago in your local timezone is:
# perl -MPOSIX -le 'print strftime(%A,localtime(time-(24*60*60)))'
You can use any of the 'strftime(3C)' formatting directives you want.
If you want the full date for yesterday, simply do:
# perl -le 'print scalar localtime(time-24*60*60))'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 07:01 AM
11-06-2006 07:01 AM
Re: Script using TZ variable
Thanks for the quick solution.
I wanted to know is there any posibility of going backdated by two days using "TZ" variable.
For Ex:
Today 06/Nov/2006
I have to go to 04/Nov/06.
The above solution from you solves the problem.
TIA,
Vishwanath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 12:16 PM
11-06-2006 12:16 PM
Re: Script using TZ variable
> Before DST Changes:
> TZ = MET
> After DST Changes:
> TZ = MET-1METDST
This does not make any sense. TZ=MET means there is no offset from UTC (or GMT) time. So the value TZ=GMT0 and TZ=MET produce the same result. And because there is no daylight saving extension, TZ=MET never changes time. It looks like someone misunderstood the purpose of the TZ variable and the /usr/lib/tztab file. If your timezone is 1 hour to the east of GMT and 2 hours east of GMT during daylight saving, then the only value for TZ should be MET-1METDST. The man page for environ and the comments in tztab will help. The global value for TZ in in /etc/TIMEZONE.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 02:12 PM
11-06-2006 02:12 PM
Re: Script using TZ variable
Do yourself a favor and forget about using TZ as a method to manipulate dates. It's a hack! It's error prone. Learn to do it properly
Google the itrc with something like:
+site:itrc.hp.com +yesterday +script
or
+site:itrc.hp.com +calculate +date +script +hpux
or...
+site:itrc.hp.com +caljd
That caljd is a very universal script.
Personally I use short perl scripts and time/localtime adding or subtrating 86400 seconds for each day.
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 05:52 PM
11-06-2006 05:52 PM
Re: Script using TZ variable
As mentioned i have first solution provided by James. I am currently in process of learning PERL scripting. Hope my life will be easier once i am done.