Time

To see what time it is type:

date

And to set it:

date<MMDDhhmmYYYY> where the syntax follows (Month, Day, hour, minute and Year).

Time is vital for compilation since the version are determined on time. Having the systems clock running behind actual time will be very problematic since files would appear as created in the future. You get warnings as:

make[1]: warning: Clock skew detected. Your build may be incomplete.

make[1]: Warning: File `scripts/kconfig/.zconf.tab.o.cmd' has modification time 4.1e+03 s in the future

UTC

Do not look where on the globe the timezone UTC is. UTC is not a timezone, it is the mechanism explained below.

To allow working globally, the following sequence could be normal saving a file in Europe and then another file some seconds later in New York. Even the clock in Europe York is hours behind, it should be made sure that everybody on the globe sees that the file in New York got saved after the one in Europe.

Linux uses for this purpose a mechanism UTC (Universal Time Coordinated), all Computers save time in GMT on their hard disks. When showing the date on screen, the computer takes GMT (Greenwich Mean Time) saving time of on the hard disk, knowing the local computers timezone, it can calculate the date to be shown.

Configuring the timezone in text mode can be very confusing. Gentoo points you to a directory full of subdirectories. If you don’t live in the GMT timezone, you are basically lost since you probably do not know what to type in.

The computer has therefore to know if the local real time clock is set to local time or GMT.

Windows assumes that the real time clock on your motherboard shows local time. Linux allows both local time or GMT = UTC (except when not daylight saving time is active). If you run Windows and Linux on the same computer and the clock jumps back an forward one hour than you should make sure Linux uses local time CLOCK="local" for the real time clock /etc/conf.d/clock.

Set also the timezone where your computer is by something as:

cp /usr/share/zoneinfo/GMT /etc/localtime

NTP

NTP allows you to get the time via Internet from a time server as https://time.is/UTC uses.

emerge ntp

You need some time servers close to you, check:

http://www.pool.ntp.org/

Find your Country:

Find the servers in your country:

server 2.ch.pool.ntp.org

server 1.europe.pool.ntp.org

server 2.europe.pool.ntp.org

To test:

tracepath ch.pool.ntp.org

emerge net-analyzer/netselect

netselect -s 3 ch.pool.ntp.org

Edit /etc/conf.d/ntp-client to point to something closer to your computer

NTPCLIENT_CMD="ntpdate"
NTPCLIENT_OPTS=" -b -u ch.pool.ntp.org europe.pool.ntp.org"

There is also the ntpd daemon that keeps the time synchronized it has a config file /etc/ntp.conf file (sample is in /usr/share/ntp)

To set your time at boot run

rc-update add ntp-client default

to have it synchronized when running

rc-update add ntpd default

Now start them:

/etc/init.d/ntp-client start

/etc/init.d/ntpd start

ntpq -c rv | grep stratum

processor="i686", system="Linux/2.6.17-gentoo-r4", leap=11, stratum=16,

Check after some hours the stratum should go towards 3

ntpq -c pe

Be aware that especially setting the clock back creates files in the future and warnings as clock skew show up when you compile such files. Disable ntp and set the clock to the future helps for the moment but stop working until time goes ahead.

This explains why ntp should be started at boot.

RTC chip on the motherboard

Time under Linux is not precise something like 10 minutes ahead. Make sure that you have compiled your kernel with the real time clock device (RTC) driver.

There is also a rtc useflag to be set and the kernel device drivers to access the motherboards rtc chip. Settings are to synchronize the rtc chip with the linux time are to be made in /etc/conf.d/clock. This is important for systems without ntp.

If you have ntp running, you would probably like to set the hardware clock to the correct time. This can be done during shutdown by setting

clock_systohc = "yes"

in /etc/conf.d/hwclock (or do nothing since this is the default).

Gateways and Routers

Gateways have often a clock inside and can make use of ntp as protocol (RFC1305) and type in a sever name as ch.pool.ntp.org.


Linurs Servernest startpage