Raspberry Pi A case and workaround for invalid calibration time using Ntpdate

Source: Internet
Author: User
Tags local time

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.