Set time during day for device to run an update and/or reboot

Hi, I have devices that should only be rebooted when they are not busy at certain times during the day. If I deploy an update is there an easy way to set a specific time during the day that the device should install the update and reboot then if needed. Should this be handled in a script or is there a setting to set the time to check? I know there are interval settings, but a specific time would be much better in my case.

State scripts are probably the most appropriate for this,

And you probably just want to halt the reboot in ArtifactReboot_Enter, until it is an appropriate timing

That’s what I was thinking… Thank you!

Hi @mirzak. Is there any way to force reboot after an application update. I tried ArtifcatCommit Script to force a reboot but it enters an infinite loop kind of state where it keeps on rebooting.

You can do that in an ArtifactCommit_Leave script, but you need to record somewhere that you are calling reboot, and next time jump over it. This is because Mender will think the script was interrupted and will retry the script on the next boot.

@kacf Thanks for the reply. This is exactly whats happening to me it keeps rebooting. I think I will use a text file to keep track of the reboot.

@kacf Can you please mention a way by which I can prevent this script from running. I am already into that infinite reboot thing and seems like I cant cancel the deployment from the web UI. How can I cancel that process on the device end.

Unfortunately you can’t, but any client version after 2.0 will eventually break out of the reboot loop (after many reboots, probably more than 10, maybe as many as 50) and recover. However, note that in this case it will not report its status to the deployment, so you will have to look at the last-checked-in status instead. This is because breaking out of an infinite loop is a very critical error and the client essentially resets everything to the base state. In order to avoid having the client download the same update again, you must also cancel the deployment.

Another way to solve this is by using Scheduled deployments, which is available in Professional and Enterprise plans. This will manage the schedule on the server-side rather than the device and may be a bit simpler.

I am not sure if this is an option for you, but wanted to mention it just in case.