Here is the script. Its a bit rough but it works ok.

#!/bin/bash
#Check to see if the weather station is working


if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then
        echo "Process $(basename $0) is already running run killall 
$(basename $0) to stop it if you want."
        exit 1
fi


FILENAME="/var/www/html/weather/index.html"
FILENAME2="/tmp/$(basename $0)2"
BROKEN="NO"
minutes2check=15
REASON="Weather station broken"
time=$(date +%k%M)

if [ $(( (`date +%s` - `stat -L --format %Y $FILENAME`) > 
($minutes2check*60) )) == 1 ] ; then

        REASON="Restarted weewx because  $FILENAME is outdated."
        #lets try just restarting the weewx to see it that works then wait 
6 minutes
        #if it is still not working then turn the console off and on

        /etc/init.d/weewx restart
        wee_reports
        echo $(basename $0) Weather station $REASON| /usr/bin/mail -s 
"Weather station $REASON" [email protected] 
        sleep 360

        #check the file again
        if [ $(( (`date +%s` - `stat -L --format %Y $FILENAME`) > 
($minutes2check*60) )) == 1 ] ; then
                BROKEN="YES"
                REASON="Rebooted console because  $FILENAME is outdated."
#I use heyu to turn on and off X10 power supply which is hooked to the relay
                /usr/local/bin/heyu on c4
                sleep 15
                /usr/local/bin/heyu off c4
                sleep 15
                /etc/init.d/weewx restart

                echo $(basename $0) Weather station $REASON| /usr/bin/mail 
-s "Weather station $REASON" [email protected] 
                #might check for unstable read in syslog file and if so 
will stop weewx and then run wee_device --clear-memory
                #the above has happened before

        fi
fi


On Tuesday, 15 May 2018 21:51:19 UTC+10, Michael Messer wrote:
>
> Greg, that's brilliant!  If I thought I'd have some free time, I'd ask 
> about the code for the cron job script, etc.  I better not!  
>
> Sounds like you're very well-prepared.  Thanks for your input!
>
> On Mon, May 14, 2018 at 9:17 PM, Greg from Oz <[email protected] 
> <javascript:>> wrote:
>
>> I took the battery out of my console...permanently and I put in a 
>> normally closed relay into the 5V of the usb cable that goes to the console.
>> I run a cron job that checks to see if the weather index.html file has 
>> NOT been changed in 20 minutes. If is has not then the same script restarts 
>> weewx. If it still doesn't update then the home automation turns on the 
>> power to the relay and it opens and drops the power to the console and 
>> resets the console. Weex is started again.
>> If all of that doesn't work then the script runs  wee_device 
>> --clear-memory
>>
>> if all of that doesn't work I have a backup console...........
>>
>> Touch wood...I haven't had any issues with the fineoffset console for 
>> years. I wrote the script when I was USING cumulus....it locked up lots.
>>
>>
>> On Sunday, 13 May 2018 23:42:24 UTC+10, Michael Messer wrote:
>>>
>>> All:  I posted here about being unable to resolve fine offset USB errors 
>>> preventing my
>>>
>>  
>>
>>> Ambient WS-2080 weather station's data from getting up to the Weather 
>>> Underground.
>>>
>>> All attempts involving resetting the weather station console did not fix 
>>> it.  Even wiped my SD card and went back to a known GOOD image from when I 
>>> first set up Weewx successfully.  Same errors.
>>>
>>> Today I decided to connect the console to my old laptop and run Cumulus 
>>> to see if Cumulus would, too, be unable to get data.  Upon connection, 
>>> Cumulus immediately began displaying the data from my weather station!
>>>
>>> I looked for some way to get Cumulus to maybe reset my console, but saw 
>>> no such options.  
>>>
>>> Just for grins, I restarted my Rapsberry Pi, connected the console, then 
>>> started Weewx.  Boom.  Instant connection, no FOUSB errors!  
>>>
>>> So my guess is that my Cumulus session somehow cleared some sort of 
>>> issue within my PWS console.  
>>>
>>> Not 100% comfortable since I still have no idea how/why FOUSB issues 
>>> started, but at least it looks like I now know of a fix!  Hopefully I'll 
>>> get another couple of years of good service from my Pi and Weewx, and when 
>>> I win the lottery I'll get a new top-of-the-line weather station... and 
>>> will install it at my new house.  Maybe in Fiji or Italy or Colorado.  Or 
>>> all of the above.
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "weewx-user" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/weewx-user/WETchOWLPsE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to