Simple guide to scheduled reboot and reboot from phone app

This goes for UI7

Scheduled Reboot

  1. Go to Scenes → Add Scene
  2. Click schedule and set the interval and click “validate”
  3. Click “Next Step”
  4. Click “Next Step”
  5. Click “No Loop Code Defined” and type in os.execute( ‘reboot’ ) and click “Save Lua”
  6. select room and name your scene and click fininsh

Manual Reboot

  1. Go to Scenes → Add Scene
  2. Click “Manual”
  3. Click “Next Step”
  4. Click “Next Step”
  5. Click “No Loop Code defined” and type in os.execute( ‘reboot’ ) and click “Save Lua”
  6. select room and name your scene and click fininsh

Now you can run that scene from your mobile to manually reboot Vera.

Beware; when there is no internet connection , it is not good to reboot the vera.

This code first checks if there is internet connection, otherwise it doesn’t reboot.
Before someone made this script for me , once the vera was stuck due to no internet connection after a reboot.

local ping = os.execute("ping -c 1 8.8.8.8") if ping ~= 0 then luup.log("Auto Reboot: Network down. Aborted.") else luup.log("Auto Reboot: Network OK. Rebooting in 2 seconds.") luup.sleep(2000) os.execute("reboot") end

Cor

Thank you!
You mean like this:

Scheduled Reboot

  1. Go to Scenes → Add Scene
  2. Click schedule and set the interval and click “validate”
  3. Click “Next Step”
  4. Click “Next Step”
  5. Click “No Loop Code Defined” and type in:
    local ping = os.execute(“ping -c 1 8.8.8.8”)
    if ping ~= 0 then
    luup.log(“Auto Reboot: Network down. Aborted.”)
    else
    luup.log(“Auto Reboot: Network OK. Rebooting in 2 seconds.”)
    luup.sleep(2000)
    os.execute(“reboot”)
    end
    and click “Save Lua”
  6. select room and name your scene and click fininsh

But this also means it wont reboot if Google is down “(8.8.8,8)” :slight_smile:

Correct … but you don’t want to reboot your vera without internet … something to do that vera needs a time from internet when rebooting.

I for example have a schedule for daily reboot at 0330, but you can also leave it open and just use it for a manuel reboot.

Cor

Yes, know about that time thing.

On the other hand, one can’t even reboot it remotly if there is no internet :slight_smile:

My scheduled reboots are twice a week at 04:00

I just want to be able to reboot every device remotely if I’m away, rarely needed option but still.
And that goes for all internet connected devices: Modem, router, Vera, Alexa, NVR etc.
Now I’m all set with that :slight_smile:

Vera contacts OpenWRT NTP servers on a boot—there is no hardware RTC. Vera will be cranky if it can’t contact the time servers. Using a scene to remotely reboot assumes a couple of things: 1) Vera has network connectivity, and 2) Vera is running well enough to accept the remote command.

I use the os.command method for a daily scheduled reboot—you can also use the same scene run manually, of course, to reboot on demand. I run a local NTP server, so outside connectivity isn’t needed to reboot. There are some threads on the forum that cover this topic. For the scheduled reboot, adding the network check code is a must if you don’t run your own NTP. Even so, I use that code to test the NTP server before attempting the reboot.

If Vera isn’t running, then options are obviously limited for a reboot. My Vera’s are on network-connected power relays that ping the units once per minute. If 2 pings are missed, it will power cycle the unit. They can also be controlled from the network, including remotely. All the key network equipment is set up like this.

There are possible downsides to a remote reboot. The forum has some horror stories of folks who had a remote unit fail the reboot, necessitating a long trip to the remote location to debug the problem.

[quote=“Cor, post:2, topic:198676”]local ping = os.execute("ping -c 1 8.8.8.8") if ping ~= 0 then luup.log("Auto Reboot: Network down. Aborted.") else luup.log("Auto Reboot: Network OK. Rebooting in 2 seconds.") luup.sleep(2000) os.execute("reboot") end[/quote]

A shorter, simpler version of this is:

os.execute("ping -c 1 && reboot")

The reboot command will not run unless the exit status of ping is 0 (can reach Google).

Nice, what does the “&&” stand for?

Logical AND operator

from: Lists (Bash Reference Manual)

An AND list has the form

command1 && command2
command2 is executed if, and only if, command1 returns an exit status of zero.

But where in this line does it ping google ?: os.execute(“ping -c 1 && reboot”)

Could somebody post the real/right/best/working line of code to put in?

Maybe with some cache clearing included?

Sorry! My bad…

os.execute("ping -c 1 8.8.8.8 && reboot")

What cache are you referring to?

I’m new to this so I’m not sure, but i read a post where somebody had some kind of script that cleared unnecessary files/cache before
scheduled reboot. Some kind of “maintenance”

Don’t know if it’s necessary, but would gladly put that in the reboot lua if it helps Vera function properly.
Like starting from as “clean table” as possible. :slight_smile:

The script was: os.execute(“echo 3 > /proc/sys/vm/drop_caches”)

Just dont know if that helps anything, and how to put that in to the rest of the script ?

And thanks Rigpapa and Cor for the scripts.

That would flush a bunch of caches that are volatile, so they’re being flushed by the reboot anyway. Flushing them may have some use if you’re not rebooting, maybe reducing memory use temporarily, but these are well-managed caches and unless you’re really strapped for RAM for some immediate purpose, flushing them is more likely to create a momentary negative impact on system performance.

Ok, so thats sorted out then.
I’ll just stick to the: os.execute(“ping -c 1 8.8.8.8 && reboot”) and see how it acts.

This cache-flush came from another thread and was apparently recommended by Vera support, at least for one user. Cache management is part of the OS, and as @rigpapa points out, works well. I would not execute this command unless I had a specific situation where I knew it would help. If free memory drops to dangerous levels, the OS OOM (out of memory) killer may start killing processes to preserve the system. Dealing with this sort of behavior is the province of experienced system admins. My systems are VPs, which do have more memory than the VL, VE, or V3, so I may be having a better experience than users on those platforms.

I have Vera Secure.
What’s the easiest way to see the amount memory used? And system logs?

[quote=“thief, post:18, topic:198676”]I have Vera Secure.
What’s the easiest way to see the amount memory used? And system logs?[/quote]

Install ALTUI from the App store. It has built in utilities to show memory and “disk” usage, display logs, search for errors within logs, as well as the ability to run OS commands.

To dump the current log in your browser: http://your_vera_ip_address_here/cgi-bin/cmh/log.sh?Device=LuaUPnP

Thanks!