more G-Labs products

Author Topic: scripted restart and reboot  (Read 1245 times)

June 18, 2016, 05:10:58 PM
Read 1245 times

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
Can anyone help me get started with some code to schedule, based on cron event, a reboot of an RPi and restart of HomeGenie.

I have a couple of headless RPi's around the house and garden which I like to reboot once every 4 weeks and restart HG every 2 weeks, and start up in the same state as prior to the reboot/restart. This as part of standard system maintenance I do with all my equipment. I have similar scripts running for my routers and server.

I played with cron and script in Raspbian to reboot the RPi, but then it starts with all X10 devices switched on every single time.

I guess there must be an option using C# to do this in a clean and controlled way.

4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

June 20, 2016, 12:18:44 PM
Reply #1

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
Here's some code:
http://www.homegenie.it/forum/index.php?topic=1214.msg7616#msg7616

I use a script with:
Program Code: HomeAutomation.RPIREBOOT/1 .ControlOn
Trigger: HomeAutomation.HomeGenie/Automation .Scheduler.CronEvent equals @sevenAMEveryDay

June 20, 2016, 05:56:22 PM
Reply #2

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525

June 24, 2016, 12:21:14 AM
Reply #3

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
I'm not being funny but scheduled restarts just sound plain wrong to me (I work in IT)

Unless you have a memory leak then It just seems wrong! I would also want a bit more intelligence to control when and where they could do it (IE flags set to prevent it rebooting if something is happening, IE lights on or something it controls) and probably also use MQTT to broadcast a message to other nodes and then take recovery actions automatically if the box doesn't return to the network as expected, Or even make other nodes take over its job whilst it reboots..

Depends how anal you are, but for me stuff shouldn't go down.. That's where you don't really want to rely on anything other than embedded style electronics but..

The esp8266 stuff I have done for controlling lights will all still work without HG, HG just takes part in what it does but isnt a key component :)

June 24, 2016, 01:15:32 AM
Reply #4

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
I travel al lot, really a lot, international. Things always freeze  or something goes wrong when I'm not home. since I started with scheduled restarts I never have issues. So no panic calls from the wife when I'm in Kuala Lumpur or in Dubai. The equipment never fails when I'm home, but as soon as I leave weird things happen.

4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

June 26, 2016, 10:55:56 PM
Reply #5

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271

July 31, 2016, 11:27:43 AM
Reply #6

innovauta

  • *
  • Information
  • Newbie
  • Posts: 2
Hi enterprised, I also travel a lot and I'm seraching for a scheduled restart.
I have seen other alternatives posted by bkenobi and jshan but not the solution you found.
Could you help me with some code to schedule?

Thank you!