Setting Up NTP on Raspberry Pi “Bookworm” for Accurate Timekeeping

image_print

Introduction

Accurate timekeeping is essential for various applications, from logging to scheduling tasks. While there are numerous public NTP servers, setting up your own NTP server offers more control and can be quite satisfying. In this blog post, we’ll explore how to configure a Raspberry Pi, affectionately named “Bookworm,” to sync time using an NTP server.

Why Raspberry Pi?

The Raspberry Pi is a versatile and affordable piece of hardware that can handle a variety of tasks, including acting as an NTP client. Its low power consumption and ease of use make it an ideal choice for this purpose.

Prerequisites

  • A Raspberry Pi running a compatible Linux distribution (e.g., Raspbian)
  • Basic knowledge of Linux commands and vi text editor
  • Access to an NTP server (In this example, we use 192.168.0.1)

Step-by-Step Guide

  1. Check Current Time Sync Status
   timedatectl show-timesync --all

This command will display detailed information about the current time synchronization status on your Raspberry Pi.

  1. Edit the Configuration File
   sudo vi /etc/systemd/timesyncd.conf

Open the timesyncd.conf file using the vi text editor with superuser permissions.

  1. Set the NTP Server
   NTP=192.168.0.1

Add this line to the timesyncd.conf file to specify the NTP server you want to use. Save and exit the file.

  1. Restart the Time Sync Service
   sudo systemctl restart systemd-timesyncd

Restart the systemd-timesyncd service to apply the changes.

  1. Verify the Changes
   timedatectl show-timesync --all

Run this command again to confirm that the NTP server is now set to 192.168.0.1.

  1. Check the System Time
   date

Finally, use the date command to display the current system time, ensuring that it is accurate.

Conclusion

Configuring your Raspberry Pi “Bookworm” to use a specific NTP server is a straightforward process that ensures accurate timekeeping. This setup is particularly useful for networks where precise time is crucial. With these simple steps, you can achieve better control and reliability in time synchronization.

I hope you find this guide useful for setting up NTP on your Raspberry Pi “Bookworm.” Feel free to adapt these steps according to your specific needs.

You may also like...