This script is designed to run on QNAP NAS devices to override their unreliable and inconsistent native time synchronization behavior. It stops all built-in time sync mechanisms, neutralizes crontab hacks, and sets up a clean ntpd daemon using your own configuration.
QNAP's native time synchronization implementation is notoriously problematic:
- It frequently relies on
ntpdateor custom scripts likeadjust_timethat can conflict with each other. - Time sync is often configured redundantly in both cron jobs and services.
- Hardware clock sync behavior is chaotic, leading to inconsistent system times, especially after reboots.
This script disables the mockery from QNAP’s crontab and re-establishes a clean, reliable time sync routine based on an ntpd service using your own ntp.conf file.
- Disables all QNAP-generated cron jobs related to
hwclock,ntpdate, andadjust_time. - Stops all time-related daemons (
ntpdated,ntpd) and kills any leftover processes. - Sets the system clock from the hardware clock.
- Syncs the system time with your own NTP server.
- Updates the hardware clock from the system clock.
- Restarts cron and launches a proper
ntpddaemon using your own configuration file.
- A working NTP server (e.g., on your LAN) that needs to be set in the
$NTP_SERVERvariable - A valid
ntp.conffile stored under path: such as/share/YOURCUSTOMPATH/ntp.confthat is set in the$NTP_CONF_SRCvariable - Admin/Root access on your QNAP device
- Familiarity with
autorun.shfunctionality
This script is intended to run automatically at boot using QNAP’s autorun.sh mechanism.
ℹ️ This script is aimed at advanced users. It assumes you already know how to install and configure
autorun.shon your QNAP device.
Inside QTS (the QNAP admin interface):
- Go to Control Panel > Date and Time
- Set time sync to manual
- Make sure NTP Server application is disabled
This ensures QTS won't interfere with the time settings after the script runs.
Before rebooting execute the script and check whether it's working. Some ntpd.conf files cause ntpd to crash so check the output of ntpq -pw. If all goes well and ntpd does not die after a few minutes, you might want to try rebooting your QNAP to test whether it is properly executed at boot time.
Created by a frustrated QNAP user who needed time to actually make sense.
Use at your own risk. This script directly modifies cron jobs and system services. Make sure you understand what it does before using it.