- 论坛徽章:
- 0
|
正好不久前看到《How Linux Works:What Every Super-User Should Know》中的解释:
A well-functioning Unix machine depends on accurate timekeeping. The kernel is responsible for maintaining the system clock, the clock consulted when you run commands such as date. You can also set the system clock with the date command, but this is usually a bad idea, because you'll never get the time exactly right. You want your system clock to be very close to the correct time.
PC hardware has a battery-backed "real-time" clock. It's not the greatest clock in the world, but it's better than nothing. The kernel usually sets its time based on this clock at boot time, and you can reset the system clock to the current hardware time with hwclock. If your hardware clock is in UTC (Universal Coordinated Time, or Greenwich Mean Time), run this command:
hwclock --hctosys --utc
Unfortunately, the kernel isn't terribly good at keeping time, and because Unix machines often stay up for months and years at a time, they tend to develop a drift. In addition, it's fairly rude to make the system clock jump ahead or back by running hwclock on a frequent basis; time-based system events can get lost or munged. If you want to gradually change the system clock based on the hardware clock, run this command:
adjtimex --adjust
However, this is only good for updating the clock manually when it has already drifted. To keep the time up to date, you need to run a network time daemon
[ 本帖最后由 hahasasa 于 2008-7-3 16:29 编辑 ] |
|