Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

41 Commits

Repository files navigation

ntpdate

NTP Time Sync Script

GitHub Workflow StatusPerl Version

This Perl script synchronizes the system time with an NTP server and updates the system clock. Please report any bugs or feature requests to the author. This module is provided as-is without any warranty.

Features

  • Retrieves network time using an NTP server.
  • Implements retry logic (up to 3 attempts) if time retrieval fails
  • Converts and formats the time using DateTime.
  • Supports configurable timezones via config.cfg.
  • Logs events using syslog.
  • Updates the system clock (requires sudo privileges).

Requirements

  • Perl
  • Required Perl Modules:
    • Net::NTPTime
    • DateTime
    • Sys::Syslog
    • Config::Abstraction
  • Linux-based system, or similar (for date command execution)

Installation

Clone the Repository

git clone https://github.com/nigelhorne/ntpdate.git
cd ntpdate

Install Dependencies

cpanm Net::NTPTime DateTime Sys::Syslog Config::Abstraction

Usage

Run the script with an NTP server:

perl ./ntpdate pool.ntp.org

Configuration

To change the default timezone, create a ~/conf/ntpdate file:

timezone=America/New_York

GitHub Actions

This project includes a GitHub Actions workflow to:

  • Install dependencies
  • Run the script with a test NTP server
  • Lint the Perl script

Logging and Error Handling

  • If the script fails to retrieve the time, it will retry up to 3 times before exiting with an error.
  • Logs are recorded via C for debugging and monitoring.

Licence Agreement

Personal Use:

This program is free to use for a single individual on one computer for personal, non-commercial purposes only.

Restricted Use:

Any other use—including but not limited to commercial, charitable, educational, or government organizationsrequires a written license agreement.

License Application:

Organizations or individuals falling outside the personal-use terms must request written permission and obtain a license before using this program.

For licensing enquiries, please contact: < njh @ nigelhorne.com >.

This module is provided as-is without any warranty.

About

Simple NTP client

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages