Raspberry Pi is not like the motherboard of the PC with a battery for the timing after the shutdown, each time the board starts to re-time, netizens generally provide the method is to use the Ntpdate network calibration, but the board is not even mobile network, because the mobile firewall will intercept the relevant access.
For detailed installation and configuration of this calibration service, there are a lot of links to the relevant articles, and we will not repeat them here. Let's just say that after I installed this service on Raspberry Pi 2, there was a situation where time was not calibrated, and the solution was, to be exact, that it was only a supplement to the installation tutorials of other people.
Let's take a look at the flow of mainstream configuration Ntpdate services:
$ sudo apt-get install Ntpdate # installer
$ tzselect # Select the time zone you want to match
$ sudo ntpdate cn.pool.ntp.org # update time
$ date # Verify that the time is correct
As for the boot, it seems that my Raspberry Pi 2 after the installation of the service is self-booting, do not need to manually start.
Usually you can configure the service and calibrate the Raspberry Pi time by following the procedure above. However, now that I have installed the software, the time remains unchanged. In addition, after executing the ntpdate cn.pool.ntp.org command, the NTP socket is in use, the reason is that the current Ntpdate program will help you select the server address after you tzselect the selected time zone, no need to manually specify which server to use. Of course, you can also use the command
$ sudo service NTP stop
To stop the NTP service, after executing this command, you can then manually specify the server address with Ntpdate.
However, after performing these actions, the Raspberry Pi time remains the same, except that the time it shows is always a universal Time (Universal times) provided by Ntpdate, which is not what we want to see, after the time zone is configured with the Tzselect command, This command shows the correct local time, as follows
The option step to the diagram after selecting the "Yes" item, there will also be a very important message to print out, as follows
At the beginning of the tutorial of others, there is no screenshot of this message, so I did not look carefully, back to find that it is so useful. This tip tells us that if you want to make this change permanent for yourself, you will
tz= ' Asia/shanghai '; Export TZ
Added to the. profile file in your home directory. Of course, if we want all users to follow this set of time, this paragraph should be added to the/etc directory in the profile file.
Following that message, I modified my user's profile as follows
$ cat << EOF >>. Profile
> tz= ' Asia/shanghai '; export TZ
> EOF
Then reboot the system.
$ sudo reboot
After the board restarts, re-login to my user account, in the VNC GUI can see my time synchronization into that local time.