[ Pobierz całość w formacie PDF ]
.Those that do, do not agree when theclocks should be moved, and they change the rules from year to year.This makestime zone conversions de nitely non-trivial.Time zones are best named by the location or by telling the di erence betweenlocal and universal time.In the US and some other countries, the local time zoneshave a name and a three letter abbreviation.The abbreviations are not unique,however, and should not be used unless the country is also named.It is better to talkabout the local time in, say, Helsinki, than about East European time, since not allcountries in Eastern Europe follow the same rules.Linux has a time zone package that knows about all existing time zones, and thatcan easily be updated when the rules change.All the system administrator needsto do is to select the appropriate time zone.Also, each user can set his own timezone this is important since many people work with computers in di erent countriesover the Internet.When the rules for daylight savings time change in your local timezone, make sure you'll upgrade at least that part of your Linux system.Other thansetting the system time zone and upgrading the time zone data les, there is littleneed to bother about time.11.2 The hardware and software clocksA personal computer has a battery driven hardware clock.The battery ensures thatthe clock will work even if the rest of the computer is without electricity.The hardwareclock can be set from the BIOS setup screen or from whatever operating system isrunning.The Linux kernel keeps track of time independently from the hardware clock.During the boot, Linux sets its own clock to the same time as the hardware clock.After this, both clocks run independently.Linux maintains its own clock becauselooking at the hardware is slow and complicated. 11.3.Showing and setting time 102The kernel clock always shows universal time.This way, the kernel does notneed to know about time zones at all the simplicity results in higher reliability andmakes it easier to update the time zone information.Each process handles time zoneconversions itself using standard tools that are part of the time zone package.The hardware clock can be in local time or in universal time.It is usually betterto have it in universal time, because then you don't need to change the hardwareclock when daylight savings time begins or ends UTC does not have DST.Unfor-tunately, some PC operating systems including MS-DOS, Windows, OS 2 assumethe hardware clock shows local time.Linux can handle either, but if the hardwareclock shows local time, then it must be modi ed when daylight savings time beginsor ends otherwise it wouldn't show local time.11.3 Showing and setting timeIn the Debian system, the system time zone is determined by the symbolic linketc localtime.This link points at a time zone data le that describes the localtime zone.The time zone data les are stored in usr lib zoneinfo.Other Linuxdistributions may do this di erently.A user can change his private time zone by setting the TZ environment variable.If it is unset, the system time zone is assumed.The syntax of the TZ variable isdescribed in the tzset 3 manual page.The date command shows the current date and time.2 For example:$ dateSun Jul 14 21: 53: 41 EET DST 1996$That time is Sunday, 14th of July, 1996, at about ten before ten at the evening, inthe time zone called EET DST which might be East European Daylight SavingsTime.date can also show the univeral time:$ date -uSun Jul 14 18: 53: 42 UTC 1996$date is also used to set the kernel's software clock:2Beware of the time command, which does not show the current time. 11.4.When the clock is wrong 103date 07142157Sun Jul 14 21: 57: 00 EET DST 1996dateSun Jul 14 21: 57: 02 EET DST 1996See the date manual page for more details the syntax is a bit arcane.Only rootcan set the time.While each user can have his own time zone, the clock is the samefor everyone.date only shows or sets the software clock.The clock commands syncronizesthe hardware and software clocks.It is used when the system boots, to read thehardware clock and set the software clock.If you need to set both clocks, you rstset the software clock with date, and then the hardware clock with clock -w.The -u option to clock tells it that the hardware clock is in universal time.Youmust use the -u option correctly.If you don't, your computer will be quite confusedabout what the time is.The clocks should be changed with care.Many parts of a Unix system require theclocks to work correctly.For example, the cron daemon runs commands periodically.If you change the clock, it can be confused of whether it needs to run the commandsor not.On one early Unix system, someone set the clock twenty years into the future,and cron wanted to run all the periodic commands for twenty years all at once.Current versions of cron can handle this correctly, but you should still be careful.Big jumps or backward jumps are more dangeours than smaller or forward ones.11.4 When the clock is wrongThe Linux software clock is not always accurate.It is kept running by a periodictimer interrupt generated by PC hardware.If the system has too many processesrunning, it may take too long to service the timer interrupt, and the software clockstarts slipping behind.The hardware clock runs independently and is usually moreaccurate.If you boot your computer often as is the case for most systems that aren'tservers , it will usually keep fairly accurate time.If you need to adjust the hardware clock, it is usually simplest to reboot, go intothe BIOS setup screen, and do it from there.This avoids all trouble that changingsystem time might cause.If doing it via BIOS is not an option, set the new timewith date and clock in that order , but be prepared to reboot, if some part of the 11.4.When the clock is wrong 104system starts acting funny.A networked computer even if just over the modem can check its own clockautomatically, by comparing it to some other computer's time [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl