1839249 Members
2509 Online
110137 Solutions
New Discussion

UNIX time change

 
Habib_4
Advisor

UNIX time change

Could someone explain how I can change the date and time on my UNIX system?

Would I be using the date -u command?

I would also like to understand the UTC time format and how to change the time using this.
Do you guys know of any comprehensive UNIX manuals for beginners that would help my understanding of UNX?

Your help in this matter will be greatly appreciated guys.

Habib
12 REPLIES 12
Peter Godron
Honored Contributor

Re: UNIX time change

Habib,
man date is your friend on how to change the time on your sysyem.

Please be aware that some applications (Oracle for example) are sensitive to date/time changes, especially backwards !

"Unix Unleashed"
http://docs.rinet.ru/UNIXs/
and others via web-search
Murat SULUHAN
Honored Contributor

Re: UNIX time change

Hi Habib

From "man date"

Set the date to Oct 8, 12:45 a.m.

date 10080045

They are lots of newbie guide or tutorial on internet

For example
http://www.google.com/search?q=unix+tutorial&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

Best Regards
Murat Suluhan
V. Nyga
Honored Contributor

Re: UNIX time change

Hi,

yes, to change it use date:
'date [-u] mmddhhmm'
'-u' is the option to set 'Input and output values in Coordinated Universal Time (UTC), functionally equivalent to Greenwich Mean Time (GMT), instead of in local time.'

See also 'man date' for the manual.
'-u' is not an option I use, without this option you can simply set the local time.

To learn more about HP-UX you can use:
http://www.docs.hp.com/en/5187-1843/index.html

or this forum!

HTH
Volkmar

*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: UNIX time change

Hi,

yes, to change it use date:
'date [-u] mmddhhmm'
'-u' is the option to set 'Input and output values in Coordinated Universal Time (UTC), functionally equivalent to Greenwich Mean Time (GMT), instead of in local time.'

See also 'man date' for the manual.
'-u' is not an option I use, without this option you can simply set the local time.

To learn more about HP-UX you can use:
http://www.docs.hp.com/en/5187-1843/index.html

or this forum!
Especially the search-function gives you much hints.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: UNIX time change

Sorry,

itrc submits faster than I thought.
0 pts. for my first reply please.

For hp-ux 11i see also:
http://docs.hp.com/en/oshpux11i.html#Installing%20and%20Updating

There are also some books spezified here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=221139

V.
P.S. the forum's etiquette
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=140137
*** Say 'Thanks' with Kudos ***
Carsten Krege
Honored Contributor

Re: UNIX time change

You should really use set_parms to change the date and time. See the manual page for set_parms.

The date/time you specify should not be earlier than the current clock value as this can cause problems.

Carsten
-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
uadm26
Super Advisor

Re: UNIX time change

Hi, Habib

You should use set_parms:
# set_parms date_time

Or stop cron:

date mmddhhmm[yy]
like today
date 091312:2806

start cron.

Good Luck,
Joel
uadm26
Super Advisor

Re: UNIX time change

Habib,
to stop and start cron use:
/sbin/init.d/cron stop
/sbin/init.d/cron start

Good Luck,
Joel
Bill Hassell
Honored Contributor

Re: UNIX time change

Note that tinezone handling is not quite the same for each flavor of Unix, so the explanations here are for HP-UX.

HP-UX has only one time -- UTC which is Universal Coordianated Time (UTC is the French abbreviation) but more popularly known as GMT (Greenwich Mean Time) or Zulu time. So when you type the command date -u, you see the time kept by HP-UX.

However, HP-UX is somewhat unique in that an UNLIMITED number of timezones can exist on the system at the same time. The reason is that all the time library and system calls will refer to a variable $TZ which contains a code for the timezone you'd like to see in your current environment. Be sure to read the man page for environ.

The TZ value has two basic parts, a symbolic name and an offset. The symbolic name is 3 or more characters such as PST or WST. The offset is the offset from UTC time where a + value is moving east from UTC, and a negative time is moving west. So PST8 means that the timezone called PST is 8 hours to the west of UTC and WST-3 is 3 hours to the east.

Now when you run the command: date, it is asking the system for the current time based on the current value of TZ. To see the value of TZ, type the command:

echo $TZ

Now if you know a bit about world time, you know that timezones are political and have very little to do with astronomy, the source of universal time. So there are dozens of timezones around the world, some are not even on the hour (they are offset -9 hours 30 minutes as in Central Australia). So to keep all of this staright, HP-UX has a file called /usr/lib/tztab which has some (NOT all) of the more common timezones listed, along with daylight saving adjustments if used. So to set the correct time of day, you can do it 2 ways:

1. Use UTC time and type the date command using the -u option as in: date -u 09131445

2. Make sure TZ has the correct timezone for your location, then type the date command without -u.

The TZ value is set for every user as you login by the file called /etc/TIMEZONE. You can display this file with the cat command.


Bill Hassell, sysadmin
Kim Jensen
New Member

Re: UNIX time change

Bill:
"UTC which is Universal Coordianated Time (UTC is the French abbreviation) but more popularly known as GMT (Greenwich Mean Time) or Zulu time. "

Not quite right. GMT is based on astronomy and UTC is based on atomic clocks.
Kindly regards Kim Jensen
http://aa.usno.navy.mil/faq/docs/UT.html

Re: UNIX time change

Bill, Kim,

As we are correcting:
"UTC which is Universal Coordianated Time (UTC is the French abbreviation) but more popularly known as GMT (Greenwich Mean Time) or Zulu time. "

Not quite right: The French abbreviation is Temps Universel Coordonne and the abbreviation UTC is a compromise between the English CUT and the French TUC.
Greetings,
Philippe Vervoort
Bill Hassell
Honored Contributor

Re: UNIX time change

Thanks Phillippe and Kim...UTC isn't that well known and I'm always asked why UTC doesn't match the full name(s). That's why I used the word "popularly" in reference to GMT. GMT is generally taken to mean UT1 which is an astronomical observation of the rotation of the earth. It turns out that this value varies quite significantly (as do all planets and stars) so GMT is not much used outside the world of astronomy and astro physics.

So the reference to GMT in tztab, the date command, the library calls like gmtime, etc, are historic. Since environ man page defines the timezone name as any 3+ character string, GMT0 should be UTC0 or better yet, ATOMIC0 (those are zeros at the end of each name). The good news in HP-UX is that you can define any timezone with a custom name and custom offset from UTC. I particularly like BILLH-3:32:20

;-)


Bill Hassell, sysadmin