Synchronize Linux Real Time Targets with Network Time Protocol (NTP) Server

Updated Apr 5, 2019

Reported In

Hardware

  • CompactRIO Controller

Driver

  • NI CompactRIO

Operating System

  • NI Linux Real-Time

Issue Details

I have a Linux Real Time Device (e.g. CompactRIO) and I am experiencing time drift. I want to synchronize its clock with the Network Time Protocol Server. How should I proceed?

Solution

  1. Before getting started, you need to enable the Secure Shell (sshd : OpenSSH Daemon) server on the Linux device via NI-MAX.
    1. Using a software to access your device in SSH (e.g. PuTTY), input the following command lines to install and configure the NTP Server:
opkg update
opkg install ntp ntp-tickadj
opkg install ntp ntp-tickadj ntp-utils
  1. The NTP server should be installed and running in the background. If the Linux device fails to update or install, make sure that the device is connected to network and that the failed links are valid webpages.
 
  1. Now you need to setup the configuration file to the NTP server of your choice. In this example, you will use the time.nist.gov server.
    1. To open the NTP Config file, run the following command
vi /etc/ntp.conf
  1. The ntp.conf file should open as VI editor.
  2. In order to modify the file, move the cursor with keyboard arrows. Add a line with server name.
  3. The file should look like this:
  1. Exit the edit mode of VI using the ESC key.
  2. Save and exit the NTP configuration file using :wq command
 
  1. Reboot the Linux Real Time target. Your target clock and time should now be synchronized to the server you specified in the configuration file.

Additional Information

  • This solution should work on Linux Real Time Targets with Real Time module 14.0 or newer.
  • For this solution to work on Real Time module 13.1 and older, you need to configure third party installation sources as mentioned in this NI forum post.
  • The configuration file works on the OS level, thus the NTP server setup will be included in the RT image, should it be copied with the Replication and Deployment (RAD) Utility.

WAS THIS ARTICLE HELPFUL?

Not Helpful