Weatther Station stops same time every week

308 views
Skip to first unread message

Monica Mulholland

unread,
Aug 24, 2024, 7:16:58 PM8/24/24
to weewx-user
Every week, on Saturday night at 11.50 pm my station stops reporting and needs to be rebooted. I am on a RPi4 (recently upgraded). Other than this little glitch, which is annoying, it is running very well since I upgraded to the RPi4.

Any suggestions of where I might look to try and sort this issue?

Any help greatly appreciated.

vince

unread,
Aug 24, 2024, 9:33:42 PM8/24/24
to weewx-user
Your system logs.

dunbrokin

unread,
Aug 26, 2024, 4:38:03 AM8/26/24
to weewx...@googlegroups.com
Apologies, yes it's always a good idea.

 For the last 3 weeks on Sat night at 11.50 it stopped recording.....but rebooting started it again the next day. However this week after rebooting it stopped at 11.10 am and despite rebooting, it never started recording again.

So I ran the log as per the instructions....but it only ran for about 6 minutes. Attached is all that was recorded in almost 15 minutes.


--
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 on the web visit https://groups.google.com/d/msgid/weewx-user/68cf6bec-901e-449d-b75a-45b3fc7c75b5n%40googlegroups.com.
mylog(2)

vince

unread,
Aug 26, 2024, 12:20:11 PM8/26/24
to weewx-user
Sigh - as always, set debug=1 and let it run for more like 35 minutes.  You have an archive period of 10 minutes if it's running off the hardware interval of 600 seconds so we need to see a few cycles.

dunbrokin

unread,
Aug 26, 2024, 4:02:43 PM8/26/24
to weewx...@googlegroups.com
Oops Sorry, I thought I had hardwired in debug=1.....bottom of the class for me on this one I think....made all the rookie mistakes. Apologies for wasting your time!


vince

unread,
Aug 26, 2024, 10:15:53 PM8/26/24
to weewx-user
Set debug=1 and maybe we can figure it out

dunbrokin

unread,
Aug 28, 2024, 3:55:24 AM8/28/24
to weewx...@googlegroups.com
OK, lets see if I can get it right this time!

vince

unread,
Aug 28, 2024, 1:57:50 PM8/28/24
to weewx-user
Let it run through the weekend and if it fails again this Saturday post whatever is logged please.

Monica Mulholland

unread,
Aug 28, 2024, 4:53:02 PM8/28/24
to weewx-user
But, it is not running at all at the moment.....it is not showing on the website. On Wunderground it says offline. Despite repeated reboots, it has not run in nearly a week.

gjr80

unread,
Aug 28, 2024, 5:16:41 PM8/28/24
to weewx-user
I have no idea what might be causing your nightly stoppage, but from the most recent log posted you almost certainly have corrupt station memory. The clues are in hardware record generation being used, WeeWX talking to the console/logger but no archive records being dowloaded and reports are generated normally but with no new data. The net effect is that WeeWX can obtain loop packet data from the console but it cannot obtain archive records. You might want to work through the Corrupt station memory section of the Troubleshooting the Davis Vantage station wiki page.

As for the nightly stoppage, once you get your station working again you might want to leave debug = 1 and post a log extract covering say 30 minutes either side of the stoppage time.

Gary

Monica Mulholland

unread,
Aug 28, 2024, 5:30:46 PM8/28/24
to weewx-user
Thank you!

Monica Mulholland

unread,
Aug 31, 2024, 6:50:55 PM8/31/24
to weewx-user
This is the log from last night from before and after the time it shuts down each week and does not restart unless the Rpi is rebooted.
mylog(3)

Tom Keffer

unread,
Aug 31, 2024, 7:08:37 PM8/31/24
to weewx...@googlegroups.com
These four lines are interesting:

Sep 01 00:00:01 weatherpi CRON[10907]: (weatherpi) CMD (/home/weatherpi/backup_weewx.sh)
Sep 01 00:00:01 weatherpi CRON[10906]: (weatherpi) CMD (/home/weatherpi/camera_image1.sh)
Sep 01 00:00:01 weatherpi sudo[10911]: weatherpi : PWD=/home/weatherpi ; USER=root ; COMMAND=/usr/bin/systemctl stop weewx
Sep 01 00:00:01 weatherpi sudo[10911]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)

First some sort of backup shell script /home/weatherpi/backup_weewx.sh is invoked, then something for a camera image. Then the user identified by uid 1000 (presumably user 'weewx'?) got elevated privileges using "sudo", then used them to terminate weewxd. This is happening at the same time as the backup script.

It feels like the backup script is deliberately terminating weewxd before starting the backup. Take a look in the script /home/weatherpi/backup_weewx.sh

As for why this is happening at midnight Sunday morning, perhaps the backup script, or something else, is invoked by crontab. Look in /etc/crontab and in /etc/cron.weekly.

-tk

Monica Mulholland

unread,
Aug 31, 2024, 8:05:43 PM8/31/24
to weewx-user
Thank you for that. Here the screenshot of the files.
Rpi_sh2.png
WPi_sh1.png

Tom Keffer

unread,
Aug 31, 2024, 8:10:14 PM8/31/24
to weewx...@googlegroups.com
Monica: you're going to have to do a little investigation. Take a look in /home/weatherpi/backup_weewx.sh. Anything in there that could cause a weekly reboot?

Also the path /etc/cron.weekly is a directory. You'll have to look inside for any files. Could any of them cause a weekly boot?

How about the file /home/weatherpi/camera_image1.sh?

I encourage you to do a little investigative forensics on your computer. It's hard to diagnose these remotely. 

I could be wrong, but I really doubt this is a weewx problem. It's something specific to your computer.

-tk

Monica Mulholland

unread,
Aug 31, 2024, 8:23:19 PM8/31/24
to weewx-user
Thanks for that Tom, I have no doubt that you are correct....as usual. I will dig around as you propose and see what I can find.

Monica Mulholland

unread,
Aug 31, 2024, 8:48:20 PM8/31/24
to weewx-user
This is the script in /home/weatherpi/backup_weewx.sh 

And what I am trying to do here is to copy the database every week to a third party location for back up purposes. This does stop weewx....but it is supposed to start it after the database is copied. As I understand it, you cannot copy the db while it is live. So I must have screwed up the commands here somewhere which stops weewx from restarting. This is what  was suggested by Chat GPT (my programming skills leave a little to be desired) as the solution. So it looks like that weewx does not restart for some reason....maybe it needs a time lapse before starting



#!/bin/bash

# Stop the WeeWX service
sudo systemctl stop weewx
if [ $? -ne 0 ]; then
    echo "Failed to stop weewx service"
    exit 1
fi

# Copy the database file (this will block until the copy is complete)
cp /var/lib/weewx/weewx.sdb /home/weatherpi/Public/weewx.sdb
if [ $? -ne 0 ]; then
    echo "Failed to copy the database file"
    sudo systemctl start weewx
    exit 1
fi
---------------------------------------------------------------------------------------------------------------------------------------
And this is what is in   /etc/cron.weekly/man-db    
Not sure where this came from...is it not part of weewx?


                     
#!/bin/sh
#
# man-db cron weekly

set -e

if [ -d /run/systemd/system ]; then
    # Skip in favour of systemd timer.
    exit 0
fi

# This should be set by cron, but apparently isn't always; see
# https://bugs.debian.org/209185.  Add fallbacks so that start-stop-daemon
# can be found.
export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"

iosched_idle=
# Don't try to change I/O priority in a vserver or OpenVZ.
if ! grep -Eq '(envID|VxID):.*[1-9]' /proc/self/status && \
   { [ ! -d /proc/vz ] || [ -d /proc/bc ]; }; then
    iosched_idle='--iosched idle'
fi

if ! [ -d /var/cache/man ]; then
    # Recover from deletion, per FHS.
    install -d -o man -g man -m 0755 /var/cache/man
fi

# regenerate man database
if [ -x /usr/bin/mandb ]; then
    # --pidfile /dev/null so it always starts; mandb isn't really a daemon,
    # but we want to start it like one.
    # shellcheck disable=SC2086
    start-stop-daemon --start --pidfile /dev/null \
                      --startas /usr/bin/mandb --oknodo --chuid man \
                      $iosched_idle \
                      -- --quiet
fi

exit 0



vince

unread,
Aug 31, 2024, 9:57:08 PM8/31/24
to weewx-user
There are multiple things in every os that run out of cron.  Don't overthink ones you don't recognize.  The one that rebuilds the 'man' db is normal.

Your /home/weatherpi/backup_weewx.sh script is really not good at all and has a major logic error in it (typical stupid ChatGPT).   As currently written the script stops weewx, copies the db, then only restarts weewx 'if' the copy failed.  If the copy works it never restarts weewx.  This is why it's not restarting.    Move the start command line to the last line in the file and that'll fix it.

If you want another way to do it, I back up mine nightly and this script has been working for maybe 10 years now without failures.  

(note - I do a gzip of the file to compress it, and it saves nightly copies so once or twice a year I need to delete old versions.  Mine would be named vp2.sdb.2024_08_30.gz or the like.  The script should be very obvious where you'd need to edit things to salt to taste so to speak.)

vince

unread,
Aug 31, 2024, 10:02:40 PM8/31/24
to weewx-user
I might add that you can probably find where it's running from if you try "sudo crontab -l -u root" or "sudo crontab -l -u weatherpi" or similarly for whatever user you think it's running as.  It is likely that it's being called from a user-specific crontab under /var/spool/cron/crontabs which is where user-specific crontabs are located.

Monica Mulholland

unread,
Aug 31, 2024, 10:27:54 PM8/31/24
to weewx-user
Thank you, so much, Vince.....much obliged indeed!

Monica Mulholland

unread,
Aug 31, 2024, 10:38:21 PM8/31/24
to weewx-user
Ah! Yes, Vince, I can see it now...the start command is totally in the wrong place! Thank you for that!
Reply all
Reply to author
Forward
0 new messages