How can I configure my devices to update only at certain hours?


#1

Hello guys! And thank you for your awesome support.

I’m trying to configure my devices to download updates only if they are under an specific time range. That’s because I don’t want my operation to be interrupted.

I think that the best solution is to create a cron job that runs a bash script each minute. This script will check the hour, and will create/delete the file under /tmp/resin-updates.lock

Is it there a better or more easy to implement solution?


#2

Yes update locking is the right way https://docs.resin.io/runtime/update-locking/ but two comments:

First, don’t just create the file, it’s not correct that way, it has to be a lockfile. Check the lockfile command https://linux.die.net/man/1/lockfile if using linux command line tools, or there are lockfile routines in other languages if you need to. (We are improving on our docs as well, working on making it more user friendly, so please share any feedback you might have)

Second, how does your application work, is it always uninterruptable? Because normally you could wrap the part of your code that is uninterruptable between update locking/unlocking (imagine an ATM: it would update lock while someone’s using it, and unlock when they’ve finished). Otherwise I think cron can be a possible way, just might be prone to corner cases.

Please also note, that update locking also blocks device restart or shutdown from the dashboard (for the same reason of keeping the device uninterrupted, in which sense update lock is a bit of a misnomer, unfortunately, it rather means “app restart lock” in practice).

What do you think?


#3

The app is always uninterruptable, only meant to update in the time range. So I’m configuring the cron job.
And I didn’t know the lockfile command, thanks for the suggestion (:


#4

Hey, let us know how does it go, we are always interested in real life setups. :wrench: