• Aucun résultat trouvé

Setting the System Clock

Constructing an HP-UX system requires setting the system clock. Many commands use the clock to accomplish their tasks.

Prerequisites and Conditions

• Monitor the system clock daily, at the least. Reset it if it is off by more than a minute.

• Keep the system clock set to the time and date broadcast by a station that accurately gives the Greenwich time (for example, WWV in the United States).

• You need not reset the system clock on a Series 300 just because you power down the system. Series 300 computers have a battery that keeps the clock current.

• On an HP-UX cluster, setting the system clock is the same as with other HP-UX systems. However, the system clock is cluster-wide. Clocks for clients synchronize with the cluster server's clock as they join the cluster, and they remain synchronized.

Setting the Time Zone

Only the superuser can change the system clock.

Set the time zone environment variable (TZ) before you set the current time and date in the environment. Set the time-zone value with a variable declaration (as shown later) in three possible files: / etc/ csh . login, / etc/rc, and / etc/profile. The time zone, TZ, can also be set from an application program with the tzset library routine.

2-22 Constructing an HP-UX System

In these files, the format looks like this:

TZ=XXXHYYY use with /ete/re

TZ=XXXHYYY use with jete/profile export TZ

setenv TZ XXXHYYY use with /ete/csh.login where:

XXX An alphabetic abbreviation of the standard time zone, usually three letters in length. For example, MST for Mountain Standard Time.

R The difference between standard local time and Greenwich Mean Time, in hours. Fraction hours indicate minutes (for example, 3:30 for Newfoundland). Positive hours move West from Greenwich (for example, use 7 for Mountain Standard Time). Negative hours move East from Greenwich (for example, -9:30 for South Australia).

YYY An alphabetic abbreviation of the daylight time zone for your area, usually three letters in length (for example, MDT for Mountain Daylight Time). Delete this part if Daylight Savings Time is not observed in your geographic area.

Within the United States, the following examples show the idea:

• In Eastern time zone, use TZ=EST5EDT

• In Central time zone, use TZ=CST6CDT

• In Arizona, where Daylight Savings Time is not observed, use TZ=MST7

For more information on setting the time zone environment variable, refer to TZ

under the environ(3) entry in the HP- UX Reference manual.

CST6CDT now has two different meanings because the United States makes the transition to Daylight Saving Time on the first Sunday in April and Canada makes the same transition on the last Sunday in April. The

/usr/lib/tztab file has this information but it requires CST6CDT#Canada to distinguish between the two.

Continue on the next page to set the time and date.

Constructing an HP-UX System 2-23

Setting the Time and Date

Once you set the time zone variable, terminate the cron process (if it is running) and execute the date command.

1. Kill the cron process.

On an HP-UX cluster, terminate cron on each clients. To terminate cron, locate the cron process information by executing:

ps -ef I grep cron

This identifies the Process ID (PID) for cron. To determine all cron processes for all clients in an HP-UX cluster, execute:

cps -ef I grep cron

With this information, terminate cron by executing:

kill pid

where pid is the process ID associated with cron (for example, 16442).

2. Set the correct time and date (using the date command) by executing:

date MMddhhmm{yy}

where:

a. MM is a two-digit integer representing the month. For example, 03 represents March.

b. dd is a two-digit integer representing the day of the month. For example, 02 represents the second day of the month.

c. hh is a two-digit integer specifying the current hour in terms of a

twenty-four hour clock. For example, 03 specifies 3:00 am and 14 specifies 2:00 pm.

d. mm is a two-digit integer specifying the number of minutes past the stated hour. For example, 04 specifies four minutes past the hour.

2-24 Constructing an HP-UX System

e. {yy} is an optional two-digit integer specifying the last two digits of the current year; this parameter may be omitted if the year is already correct. For example, 87 specifies 1987 as the current year.

When date executes, it shows the time and date on your screen.

3. Restart cron if you terminated it in step l.

To restart cron, execute:

/etc/cron

Possible Problems When Changing the System Clock

The make program is sensitive to a file's time and date information and to the current value of the system clock. While setting the clock forward will not affect make, setting the clock backward by even a small amount may cause make to exhibit extremely bizarre behavior. Avoid setting times earlier than the current system clock's value.

Making incremental backups depends heavily on the correctness of the date because incremental backups occur in relation to a dated file.

Altering the system clock can cause unexpected results for routines scheduled by cron. When setting time back, cron doesn't run until the clock "catches up" to the point from which it was set back. For example, if you set the clock back from 8:00 to 7:30 (which is not advised), cron will not begin executing until the clock again reads 8:00. If you set the clock ahead, cron attempts to

"catch up" by immediately executing all routines scheduled to run between the old time and the new time. For example, if you set the clock ahead from 9:00 to 10:00, cron immediately executes all routines scheduled to run between 9:00 and 10:00.

Constructing an HP-UX System 2-25