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.
- 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).
- Perl
- Required Perl Modules:
Net::NTPTime
DateTime
Sys::Syslog
Config::Simple
- Linux-based system, or similar (for
date
command execution)
git clone https://github.com/nigelhorne/ntpdate.git
cd ntpdate
cpanm Net::NTPTime DateTime Sys::Syslog Config::Simple
Run the script with an NTP server:
perl ./ntpdate pool.ntp.org
To change the default timezone, create a ntpdate.cfg
file:
timezone=America/New_York
This project includes a GitHub Actions workflow to:
- Install dependencies
- Run the script with a test NTP server
- Lint the Perl script
- 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.
This project is licensed under the GPL2 Licence.