Hi, hi,

The sudo implies you have this in your own / non-root crontab.  Is that correct?
If instead, you use "sudo crontab -e" so root is calling your script, then you 
can omit the sudo in the script.  That much alone may be the solution to your 
problem.

Meanwhile, you didn't say what OS you're running, but on newer systems, those 
RC / init.d scripts are often presented via legacy wrappers for use by 
systemctl.  In that case the systemctl mechanism for restarting the service 
might be less susceptible to foreground vs. background / disconnected usage.   
Meaning where you are using "sudo /etc/init.d/weewx start" from command-line 
and it works, but doesn't work from cron, substituting the systemctl equivalent 
may be a way out.

You could try these from command line to verify your system has the legacy RC / 
init.d wrappers, then substitute the the "sudo systemctl start weewx" of 
calling the init.d script directly...

Here again, however, putting any of these in a script that runs from the root 
crontab will avoid needing to prefix with sudo...

# Check status:
$ sudo systemctl status weewx

# Restart
$ sudo systemctl restart weewx

# Stop
$ sudo systemctl stop weewx

# Start
$ sudo systemctl start weewx

Regards,
Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)

> On Apr 30, 2019, at 3:10 PM, pliggen...@gmail.com wrote:
> 
> I got this running as a cronjob, and I get a mail when weewx is not running 
> when the cronjob is executed. But I don't get the script to start weewx again.
> 
> This is the last part of checkweewx.config:
> 
> [weewx]
> #how many times to try and restart the weewx process
> restarts=3
> flagLogDir=/home/pliggen/scripts
> flagFile=weewxNotRunning.txt
> startCommand=sudo /etc/init.d/weewx start
> 
> If I run /etc/init.d/weewx start in terminal it starts.
> Any tips where to check to get this working?
> 
>> Den söndag 11 oktober 2015 kl. 02:45:50 UTC+2 skrev Constantine Samaklis:
>> The script file and configuration file can be anywhere you want.
>> 
>> You can launch the script by typing: python <path>/checkWeewx.py 
>> <path>/checkWeewx.config
>> 
>> There are no changes required in the weewx.conf. You will need to just fill 
>> the pertinent information for your setup in checkWeewx.config as it is the 
>> configuration file that drives the python script.
>> 
>>> On Saturday, October 10, 2015 at 5:22:12 PM UTC-4, Arild Halvorsen wrote:
>>> This looks exciting. How do I implement this solution in weewx? Where do I 
>>> put the files. Which information is nødvenidig in weewx.conf?
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> 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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to