Weewx not waiting for time-sync

162 views
Skip to first unread message

wfs...@gmail.com

unread,
Aug 14, 2026, 2:51:54 PM (9 days ago) Aug 14
to weewx-user
I noticed after booting that weewx is starting before the time is synchronized.  See the partial log attached.  I'm a weewx pip install Version 5.4 on a Pi running Trixie based Raspberry OS Lite.  I don't think I've messed with anything and it sure looks like the weewx.service file that's active has the Requires= and After=time-sync.target  commands.

I don't know when this broke, but I'm positive it used to work.

Walt 
log3A.txt

Vince Skahan

unread,
Aug 14, 2026, 3:49:10 PM (9 days ago) Aug 14
to weewx-user
A little hard to tell without seeing debug=1 logs but is there an actual problem you’re experiencing ?

Tom Keffer

unread,
Aug 14, 2026, 4:01:28 PM (9 days ago) Aug 14
to weewx...@googlegroups.com
I assume your concern are the lines 

Aug 14 12:36:07 Pi-3 systemd-timesyncd[315]: Contacted time server [2607:f1c0:f054:5e00::2]:123 (2.debian.pool.ntp.org).
Aug 14 12:36:07 Pi-3 systemd-timesyncd[315]: Initial clock synchronization to Fri 2026-08-14 12:36:07.050420 CDT.

which occur well after weewxd has started up. You did not post the full log from boot, so we don't know if there was an earlier attempt at synchronization. Let's take a look. Try running this:

journalctl -b -u systemd-timesyncd


Compare the time to the weewxd startup:

journalctl -b -u weewx | head

Also, was there a meaningful clock correction? Is there something that is creating concern?

-tk


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/79c08560-8e07-4b39-afca-0eea029149d6n%40googlegroups.com.

wfs...@gmail.com

unread,
Aug 14, 2026, 5:33:57 PM (9 days ago) Aug 14
to weewx-user
Tom and Vince,

This time gap was only a couple of minutes, but what if the power goes out for a couple of hours?  Isn't the station time being changed incorrectly?  From my log, a couple of lines above the clock sync:
Aug 14 12:33:01 Pi-3 weewxd[985]: INFO weewx.engine: Clock error is 185.33 seconds (positive is fast)
Aug 14 12:33:02 Pi-3 weewxd[985]: INFO weewx.drivers.vantage: Clock set to 2026-08-14 12:33:02 CDT (1786728782)
Can't that cause db errors and Vantage memory being overwritten if the time is way off?
Thanks for your help.  Here's the output of those commands:
pi@Pi-3:~ $ journalctl -b -u systemd-timesyncd
Aug 14 12:32:29 Pi-3 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Aug 14 12:32:29 Pi-3 systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Aug 14 12:32:31 Pi-3 systemd-timesyncd[315]: Network configuration changed, trying to establish connection.
Aug 14 12:32:32 Pi-3 systemd-timesyncd[315]: Network configuration changed, trying to establish connection.
Aug 14 12:32:32 Pi-3 systemd-timesyncd[315]: Network configuration changed, trying to establish connection.
Aug 14 12:32:32 Pi-3 systemd-timesyncd[315]: Network configuration changed, trying to establish connection.
Aug 14 12:32:32 Pi-3 systemd-timesyncd[315]: Network configuration changed, trying to establish connection.

Aug 14 12:36:07 Pi-3 systemd-timesyncd[315]: Contacted time server [2607:f1c0:f054:5e00::2]:123 (2.debian.pool.ntp.org).
Aug 14 12:36:07 Pi-3 systemd-timesyncd[315]: Initial clock synchronization to Fri 2026-08-14 12:36:07.050420 CDT.
pi@Pi-3:~ $ journalctl -b -u weewx | head
Aug 14 12:32:53 Pi-3 systemd[1]: Started weewx.service - WeeWX weather system.
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Initializing weewxd version 5.4.0
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Command line: /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py /home/pi/weewx-data/weewx.conf
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Using Python: 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0]
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Located at:   /home/pi/weewx-venv/bin/python
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Platform:     Linux-6.18.39+rpt-rpi-v8-aarch64-with-glibc2.41
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Locale:       'en_US.UTF-8'
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Entry path:   /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: WEEWX_ROOT:   /home/pi/weewx-data
Aug 14 12:32:54 Pi-3 weewxd[985]: INFO __main__: Config file:  /home/pi/weewx-data/weewx.conf
pi@Pi-3:~ $

Tom Keffer

unread,
Aug 14, 2026, 6:29:04 PM (9 days ago) Aug 14
to weewx...@googlegroups.com
Could you post your weewx.service file?

wfs...@gmail.com

unread,
Aug 15, 2026, 7:37:11 AM (9 days ago) Aug 15
to weewx-user
pi@Pi-3:~ $ sudo systemctl status weewx
● weewx.service - WeeWX weather system
     Loaded: loaded (/etc/systemd/system/weewx.service; enabled; preset: enabled)
     Active: active (running) since Fri 2026-08-14 12:32:53 CDT; 17h ago
 Invocation: 267b6c1305ba4ad4a6f6872ade89aa05
       Docs: https://weewx.com/docs
   Main PID: 985 (python)
      Tasks: 6 (limit: 806)
        CPU: 1h 4min 27.142s
     CGroup: /system.slice/weewx.service
             └─985 /home/pi/weewx-venv/bin/python /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py /home/pi/weewx-data/weewx.conf

pi@Pi-3:~ $ cat /etc/systemd/system/weewx.service
# systemd service configuration file for WeeWX

[Unit]
Description=WeeWX weather system
Documentation=https://weewx.com/docs
Requires=time-sync.target
After=time-sync.target
Wants=network-online.target
After=network-online.target

# If you are using MySQL uncomment the following lines:
# After=mysqld.service
# Wants=mysqld.service

# If you are using MariaDB uncomment the following lines:
# After=mariadb.service
# Wants=mariadb.service

[Service]
ExecStart=/home/pi/weewx-venv/bin/python /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py /home/pi/weewx-data/weewx.conf
StandardOutput=null
StandardError=journal+console
User=pi
Group=pi

[Install]
WantedBy=multi-user.target
pi@Pi-3:~ $

John Smith

unread,
Aug 15, 2026, 8:46:47 AM (9 days ago) Aug 15
to weewx...@googlegroups.com
After=time-sync.target
Wants=network-online.target
After=network-online.target

I'm not an expert on SystemD service files but shouldn't the After= be a single line?

eg After=network-online.target time-sync.target

wfs...@gmail.com

unread,
Aug 15, 2026, 9:24:18 AM (9 days ago) Aug 15
to weewx-user
John, I'm no systemd expert either but i'm looking through the rather disorganized documentation at debian.org and i think either way should work.  But I see another reference that systemd-time-wait-sync needs to be enabled along with systemd-timesyncd.

I have timesyncd enabled but time-wait-sync is not.  Let me enable that and retest.

Walt



wfs...@gmail.com

unread,
Aug 15, 2026, 9:42:26 AM (9 days ago) Aug 15
to weewx-user
Yeah, that appears to be the problem.  I upgraded to Trixie a couple of weeks ago and it looks like wait-sync is disabled out of the box. I'm pretty sure I didn't disable it myself.  I see an extra line now in syslog just before the clock sync messages:

Aug 15 08:28:15 Pi-3 sh[1002]: Completed socket interaction for boot stage config
Aug 15 08:28:15 Pi-3 systemd[1]: Finished cloud-config.service - Cloud-init: Config Stage.
Aug 15 08:28:23 Pi-3 systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
Aug 15 08:29:22 Pi-3 systemd-time-wait-sync[283]: adjtime state 0 status 2000 time Sat 2026-08-15 13:29:22.342967 UTC
Aug 15 08:29:22 Pi-3 systemd-timesyncd[320]: Contacted time server [2600:3c02::f03c:94ff:fee2:9c6a]:123 (2.debian.pool.ntp.org).
Aug 15 08:29:22 Pi-3 systemd-timesyncd[320]: Initial clock synchronization to Sat 2026-08-15 08:29:22.342856 CDT.
Aug 15 08:29:22 Pi-3 systemd[1]: Finished systemd-time-wait-sync.service - Wait Until Kernel Time Synchronized.
Aug 15 08:29:22 Pi-3 systemd[1]: Reached target time-sync.target - System Time Synchronized.
Aug 15 08:29:22 Pi-3 systemd[1]: Started apt-daily.timer - Daily apt download activities.
Aug 15 08:29:22 Pi-3 systemd[1]: Started apt-daily-upgrade.timer - Daily apt upgrade and clean activities.
Aug 15 08:29:22 Pi-3 systemd[1]: Started dpkg-db-backup.timer - Daily dpkg database backup timer.
Aug 15 08:29:22 Pi-3 systemd[1]: Started e2scrub_all.timer - Periodic ext4 Online Metadata Check for All Filesystems.
Aug 15 08:29:22 Pi-3 systemd[1]: Started fstrim.timer - Discard unused filesystem blocks once a week.
Aug 15 08:29:22 Pi-3 systemd[1]: Started logrotate.timer - Daily rotation of log files.
Aug 15 08:29:22 Pi-3 systemd[1]: Started man-db.timer - Daily man-db regeneration.
Aug 15 08:29:22 Pi-3 systemd[1]: Reached target timers.target - Timer Units.
Aug 15 08:29:22 Pi-3 systemd[1]: Started weewx.service - WeeWX weather system.
Aug 15 08:29:22 Pi-3 systemd[1]: Reached target multi-user.target - Multi-User System.
Aug 15 08:29:22 Pi-3 systemd[1]: Starting cloud-final.service - Cloud-init: Final Stage...
Aug 15 08:29:22 Pi-3 cloud-init[520]: Cloud-init v. 25.2 running 'modules:final' at Sat, 15 Aug 2026 13:29:22 +0000. Up 40.40 seconds.
Aug 15 08:29:22 Pi-3 cloud-init[520]: 2026-08-15 13:29:22,689 - modules.py[WARNING]: Could not find module named cc_netplan_nm_patch (searched ['cc_netplan_nm_patch', 'cloudinit.config.cc_netplan_nm_patch'])
Aug 15 08:29:22 Pi-3 cloud-init[520]: Cloud-init v. 25.2 finished at Sat, 15 Aug 2026 13:29:22 +0000. Datasource DataSourceNoCloud [seed=cmdline,ds_config_seedfrom,file:///boot/firmware][dsmode=local].  Up 40.67 seconds
Aug 15 08:29:22 Pi-3 sh[1018]: Completed socket interaction for boot stage final
Aug 15 08:29:22 Pi-3 systemd[1]: Finished cloud-final.service - Cloud-init: Final Stage.
Aug 15 08:29:22 Pi-3 systemd[1]: Reached target cloud-init.target - Cloud-init target.
Aug 15 08:29:22 Pi-3 systemd[1]: Startup finished in 3.751s (kernel) + 36.952s (userspace) = 40.704s.
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Initializing weewxd version 5.4.0
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Command line: /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py /home/pi/weewx-data/weewx.conf
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Using Python: 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0]
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Located at:   /home/pi/weewx-venv/bin/python
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Platform:     Linux-6.18.39+rpt-rpi-v8-aarch64-with-glibc2.41
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Locale:       'en_US.UTF-8'
Aug 15 08:29:23 Pi-3 weewxd[1014]: INFO __main__: Entry path:   /home/pi/weewx-venv/lib/python3.13/site-packages/weewxd.py

Gotta write that down!  (And then forget I wrote it down).

Walt

John Smith

unread,
Aug 15, 2026, 10:05:46 AM (9 days ago) Aug 15
to weewx...@googlegroups.com
Gotta write that down!  (And then forget I wrote it down).

No, you'll remember you wrote something down, but won't have the foggiest what it was or where you put the piece of paper so it'd be safe :D

Tom Keffer

unread,
Aug 15, 2026, 11:20:29 AM (9 days ago) Aug 15
to weewx...@googlegroups.com
Walt, glad you figured that out.

I recall debating whether to include a dependency

After=systemd-time-wait-sync

in the service file, but decided against it because it would hardwire a dependency on the systemd time synchronization. Some people prefer ntp or chrony. The more generic time-sync.target is independent of the actual service in use. 

Raspberry Pi OS always uses the systemd time sync. It's for this reason that the wiki on the RPi mentions that you should include a dependency on systemd-time-wait-sync

Sorry it's so hidden!

I suppose a more clever install script could vet what time service is in use and make the appropriate dependency.

-tk



wfs...@gmail.com

unread,
Aug 15, 2026, 1:16:00 PM (9 days ago) Aug 15
to weewx-user
Tom, yeah, I'm out of my league here but it's weird there's two services for this in debian, and one is enabled by default and the other is not.  sudo systemctl enable systemd-time-wait-sync "activates" time-sync.target so i did not need to change anything in weewx.service.

Just needed to turn it on.  Fun stuff!  Thanks for this awesome software!

Walt

Vince Skahan

unread,
Aug 15, 2026, 3:49:07 PM (8 days ago) Aug 15
to weewx-user
A couple quick tests on debian13 say neither time-sync.target nor network-online.target are enabled by default.

This is a vimdiff output comparing the output of:
    systemctl list-unit-files|sort|egrep "time|network"

The left side is a current raspiOS 64 bit lite, the right side is a debian13 x86_64 vagrant VM.

Reminder - the pi uses netplan (yecccch) while vanilla debian does it a little differently.

Screenshot 2026-08-15 at 12.40.55 PM.png

I use ntpsec on my weewx pi FWIW - it handles large time differences on initial startup better than the systemd borg stuff does.  Systemd doesn't run its timesync (garbage) if a ntp variant is installed. I have no idea how systemd will report time is synced (or not) in that setup.


Reply all
Reply to author
Forward
0 new messages