Text Link Ads

Friday, August 31, 2007

Tip for the day: SOLARIS CHANGING SEASONS

During a session, sometimes we have a need to change the system time for our session
only. We have used it to simulate time based testing.

export TZ=ESThhEDT

The EST set your time to Eastern
Standard Time and EDT is Eastern
Daylight Time.

hh is the number of hours you wish to change.

Example: Currently the system
date is Tue Jun 19 13:38:03 EDT 2001

and you wish to set it to yesterday at the same time. You would substitute a positive
29 for hh.

export TZ=EST29EDT

Now the shell time is:
Mon Jun 18 13:38:50 EDT 2001

WHY 29 and not 24? The main UNIX clock is set from GMT not EST therefore you have to add 5 hours to your backward calculations to get the same exact time since EST is
GMT - 5 hours.

Use negitive numbers to set the clock into the future.

Also if you need to set the minutes and seconds it is hh:mm:ss. These are all the
number of hours, minutes and seconds from GMT that you wish to set.

This is for Solaris 2.6, your mileage may vary.

No comments: