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::NTPTimeDateTimeSys::SyslogConfig::Abstraction
- Linux-based system, or similar (for
datecommand execution)
git clone https://github.com/nigelhorne/ntpdate.git
cd ntpdatecpanm Net::NTPTime DateTime Sys::Syslog Config::AbstractionRun the script with an NTP server:
perl ./ntpdate pool.ntp.orgTo change the default timezone, create a ~/conf/ntpdate file:
timezone=America/New_YorkThis 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 program is free to use for a single individual on one computer for personal, non-commercial purposes only.
Any other use—including but not limited to commercial, charitable, educational, or government organizations—requires a written license agreement.
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.