Page 1 of 1

scheduled reboot RPi with Domoticz

Posted: Saturday 27 January 2018 13:32
by NetEye
In my case the RPi does not work after e few days.
I tryed whatchdog without result.
Now I want to schedule a reboot within the RPi.
I want to do it by: sudo crontab -e
And put in a command: 0 0 * * * sudo reboot
Is this the right way to do?
I have no idea if it works and don't know how to test it.
Can anybody help me with this.
If I posted this in the wrong area, I will replace it.
Thanks

Re: scheduled reboot RPi with Domoticz

Posted: Saturday 27 January 2018 13:57
by Siewert308SW
First of all a reboot like you do/want aint good.
"sudo reboot" doesn't take care of Domoticz which needs a proper shutdown.
Meaning, you will hit a time that your database gets corrupt.
It will happen for sure that a read/write to the database is interrupted.
There are many ways like for example a simple bash called from cron.
And then stop domoticz service and afterwards then conduct a reboot.

As for your issue that Domoticz or Rpi aint running anymore after a few days.
Instead of sticking bandages like rebooting you really should look for why it aint running anymore.
Better said, find the culprit.

Re: scheduled reboot RPi with Domoticz

Posted: Saturday 27 January 2018 22:06
by NetEye
Thank you for your quick answer.
I looked over the reasen why its stalls.
I was also finding out for a more stable electric connection.
Nothing was found wrong.
So my last thought was a scheduled reboot.... wrong asbyou said.
Will there something be damager when I do so?
I realy don’t know why the RPi stops.

Re: scheduled reboot RPi with Domoticz

Posted: Saturday 27 January 2018 22:18
by NetEye
The RPi remains running after these days but the communication with ddns or local stops.
I will then have to get whatch dog running in the right way.
I believe thats the only solution after reading your answer.

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 7:18
by Egregius
You should first determine why the Pi stops, or what part of the Pi stops.
Then use a script to monitor that service/port/connection and first try to restart that service.
If that fails you could have the script stop services and reboot.

What do you mean exactly with "the communication with ddns or local stops"?

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 9:25
by NetEye
I can not enter Domoticz local or from home via DDNS.
The only way to enter it again is a hard reset (power plug in and out), thats why I thought about a scheduled reboot.
After a reboot my project still runs with all of the history so I find no harm in a fixed reboot.
I don’t know how that monitoring works.
Maybe watchdog is an idea?
I looked it over and know hoe to start it but is there a way to start it automaticly after a reboot by a sudo in a start up file?

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 9:30
by Siewert308SW
NetEye wrote: Sunday 28 January 2018 9:25 I can not enter Domoticz local or from home via DDNS.
The only way to enter it again is a hard reset (power plug in and out), thats why I thought about a scheduled reboot.
After a reboot my project still runs with all of the history so I find no harm in a fixed reboot.
I don’t know how that monitoring works.
Maybe watchdog is an idea?
I looked it over and know hoe to start it but is there a way to start it automaticly after a reboot by a sudo in a start up file?
As mentioned earlier.
If data is being written to the database and you do a hard reboot then the change of a corrupt database is high.
But if you do think it would harm, then be my guest but do me a favor, make regular backups.

As for your service dying, Is your RPI connect via wifi or utp?

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 9:44
by NetEye
After a few hard resets by plug in and out the RPi has to be re-installed and I hope with a software reset not? Maybe I think wrong??
My RPi is connected bij utp rj45 connector cable to my router

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 10:07
by Siewert308SW
NetEye wrote: Sunday 28 January 2018 9:44 After a few hard resets by plug in and out the RPi has to be re-installed and I hope with a software reset not? Maybe I think wrong??
My RPi is connected bij utp rj45 connector cable to my router
Again, Domoticz needs a gentle reboot.
Hard reboot like "sudo reboot" doesn't shutdown Domoticz.

You need for example:
- sudo service domoticz.sh stop
- sudo reboot

As for your connection.
If it was WiFi then high likely it was the WiFi to be pointed as culprit.
I don't have experience with the specific setup as you run it.
So can't give any propper comment on that or point a sollution.
But i think you should look why the service is stopped.
Look into the logs a find a hunch why.
Also if it's a service then maybe better to write a simple bash script to watch the service and if its failen then restart service instead of rebooting.
But main thing is, find the cause as sticking bandages isn't the sollution.

Code: Select all

service=`sudo service <your_service> status | grep Active | awk '{print $3}'`

if [[ $service != "(running)" ]]
    then
                echo 'Service is not running. trying to restart the service...'
                sudo service <your_service> restart
elif [[ $service == "(running)" ]] 
	then
                echo 'Service is running...'
fi

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 10:34
by NetEye
Thanks for the helpfull advise.
I think for now those bash and checkups is to big for me.
For now I wil run watchdog as : https://www.raspberrypi.org/forums/view ... p?t=147501
on my domoticz version 4834.
After that I will look for the reason why all fails.
Thanks for your advise
I will forget the scheduled reboot

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 12:00
by DanM
I restart my system nightly - I call the json to restart Domoticz (/json.htm?type=command&param=system_reboot). I assume Domoticz own reboot command exits cleanly (although I must confess I dont know for sure).

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 15:01
by Egregius
I would suggest using the script provided in http://www.domoticz.com/forum/viewtopic ... 80#p137092
If the web gui isn't available you can't call the reboot command of domoticz.

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 15:38
by elythomaslumber
I´m running Domoticz on an very old RP since 2012 on Release 1.18 and yesterday updated to 3.8.
But all the years I had only a few sudden stopps from Domoticz. So 99% of all time it runs like a charme.

Therefore I would try to find the reason. Here are some ideas where to find a possible problem:
- I´m using a power supply which is 500mA above the proposed type
- I use only Class 10 SD cards; maybe using a different card supplier would help
- did you expand the file system? http://geek-university.com/raspberry-pi ... ilesystem/
- I'm monitoring the board devices like CPU load (normally 3-6% on my RP) and Memory usage (RAM)
- once a day I clean up the RAM via Cronjob calling this script:

Code: Select all

#!/bin/bash

free -m
sync
sudo echo 3 > /proc/sys/vm/drop_caches
free -m
Once a week on Sunday exactly 06.26 in the morning my CPU usage goes on over 90% for a very short time; dont know why but it seems that something is cleaning up something

Hope that helps a bit or give you fresh ideas...

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 16:00
by EddyG
Siewert308SW wrote: Sunday 28 January 2018 10:07
NetEye wrote: Sunday 28 January 2018 9:44 After a few hard resets by plug in and out the RPi has to be re-installed and I hope with a software reset not? Maybe I think wrong??
My RPi is connected bij utp rj45 connector cable to my router
Again, Domoticz needs a gentle reboot.
Hard reboot like "sudo reboot" doesn't shutdown Domoticz.
Are you sure? reboot is the same as shutdown -r
In modern Linux distro's the shutdown issues an init 1 or init 6 and send all processes (except init, which gets killed) the SIGTERM.
But I might be wrong.

Re: scheduled reboot RPi with Domoticz

Posted: Sunday 28 January 2018 19:47
by NetEye
I desided to listen to you all and not use the option of reboot or shutdown -r.
I overlooked all about watch dog and I successfully have it running and also have it automatically start up after a restart.
Only one problem accused after: sudo systemctl status watchdog -l
It contains a message: "cannot open /dev/watchdog (errno = 16 = 'Device or resource busy')" at one of the row.
See the picture for details.
So I can see watchdog is running and also starts after a restart.
Can anyone help me to solve this.
Looking on Google did not give me the solution.
I will also publish this problem in a new topic in this forum to reach more people.
regards

Re: scheduled reboot RPi with Domoticz

Posted: Monday 29 January 2018 16:04
by EddyG
Is "/dev/watchdog" present? If you do "ls -al /dev/watchdog" it should look like:

Code: Select all

crw------- 1 root root 10, 130 Jan 14 11:28 /dev/watchdog

Re: scheduled reboot RPi with Domoticz

Posted: Monday 29 January 2018 20:54
by NetEye
Dear Eddy,
Thanks for your fast reaction...super
When I typ " sudo nano /dev/watchdog" it says it is a device file which is empty (see both pictures 1 and 2).
Do I have to put: crw------- 1 root root 10, 130 Jan 14 11:28 /dev/watchdog in that empty file?
Or do I have to do something with: ls -al /dev/watchdog
Or do something with both?
regards

Re: scheduled reboot RPi with Domoticz

Posted: Saturday 24 April 2021 17:51
by extremeaudio
I am also toying with the idea off rebooting my domoticz server once in a while along with some shellies.

The domoticz web UI reboot command is

http://127.0.0.1:8082/json.htm?type=com ... tem_reboot

I assume this must be doing a graceful reboot unlike sudo reboot?

Along with the domoticz server, I want to issue reboot to a couple other shelly devices also, some which misbehave after some time randomly and correct when rebooted. Their reboot commands are a simple "http://192.168.1.100/reboot" type.

How can I put all of these commands into one bunch so that 1 domoticz switch reboots all of them?