I’ve read here that one can only run scripts that take no more than 60s to finish.
What’s the workaround?
What I’ve tried:
use Python Scripts to execute shell commands in subprocess, but this isn’t doable, I cannot import modules
use crontab after SSH-ing onto my HAOS box, using the Advanced SSH Terminal addon, but crontab does not seem to execute things, also I read crontab doesn’t persist there :S
Anything simple? Like running something like mtr -r -c 100 example.com for diagnostics. I could lower here 100 to 10, just used as an example.
So my question is how to best overcome the timeout limitation, not about how to actually run things. Given clear pointers I can manage that.
If you background, nohup and redirect all (3) standard channels to /dev/null it will work.
But as tom_I points out you are Off-piste here, if you need to control a long running process you would be better off with something like an MQTT integration where you control the long running job via events.
Run something, that might take 61s, but not 120s, usually. One off things when I SSH onto my box, etc. But would like to persist over reboots probably.
Hmm, nohup, haven’t used that in a while I totally forgot about it. Will check it out.
I think my best shot is to bootstrap cron to start with the Advanced SSH docker container. Starting cron and putting my stuff into /etc/periodic worked, but will break on restarts.
Hello, I have an example script: I use the Motioneye addon for video surveillance, and since motion detection doesn’t work very well, I can’t use its motion notification module because it alerts me too often to false positives (for example rapid changes in sun and clouds).
To avoid this notification spam, I created a bash script that runs 24/7 every 5 seconds so that under certain conditions it does not alert me (if the video file is very small and if there has already been a notification in the last 15 seconds).
I used to have Home Assistant unofficially set up on a Raspberry Pi with Docker, and I could manage this type of 24/7 execution via standard Linux. Now with an official Home Assistant OS, I am limited in this type of action that requires 24/7 execution because of the 60 seconds limitation (and 15 seconds on 1 command as I tested, so I can’t do sleep 30 for example because a timeout error triggers).
How could I run that kind of scripts?
I ruled out the idea of creating an automation that runs every 5 seconds, since what is repeated every 5 seconds in the script is a small part and not the entire initialization… plus it would not take into account when the last notification was without modifying the script to create a control file.
10 minutes is too long. I don’t want spam every 1-5 seconds, but I also don’t want to wait 10 minutes to be notified of a security issue, as that would be useless. I could set it to 15 seconds, but the question is, how do I use that condition in the add-on “MotionEye”?
I mean, I don’t see how to set a Home Assistant condition in MotionEye’s motion notification settings, and I don’t even think it’s designed for that (but maybe I don’t know how it works) since it’s not configured from Home Assistant but from its own add-on: Motion detection on motioneye - #9 by aceindy
In any case, I’ve already tried the solution proposed by browetd in the link I posted earlier, and now my infinite loop is working for me, writing every 90 seconds to the log as an example, so that solution should work for me. I have to adapt my script because HAOS’s busybox ls does not accept the --time-format command, but that’s not a big deal.
However, running ps -aux does not show me that script and now I don’t know how to kill it. I will look for other ps options or simply check the log.
I suppose you limit HAOS so that we can’t do things like run infinite scripts that overload the CPU/disk or similar things, but I understand that this is everyone’s problem and we use things at our own risk.
In the end, I didn’t have any problems with my scripts in my HA with Docker, I shouldn’t have any with HAOS, and that’s why I don’t quite understand that 60-second limitation. If HAOS launches all user scripts via automations (for example), we should be able to check what is running or not, just like on any other Linux system (and here it’s easier for less experienced users because of the HA interface).