Shell_command ssh not working

Hello all, I have a command that runs well in terminal window but does not run as service. One problem is timeout of 60 seconds - I need it to run for hours. I am running HA as preconfigure virtual disk so I do not have access to components.

the definition is like this:

shell_command:
  timer_test: 'ssh name@local_IP -t "sudo pkill timer.sh; /home/username/timer.sh 300"'

I have automatic login and I also have sudo without password.

as I wrote, OK in terminal, but if ran as service it never triggers. With or without single quotes, does not help. May the problem be that service runs different shell than terminal, so the SSH key for connection is not there? Thank you.

shell_command has an hardcoded timeout of 60 sec. Your command will be killed if it takes longer.

I’ve created a custom component to help both with ssh commands and timeouts

You can also use the nohup, then the script fires in background and runs forever, no component needed

For example, i use this , i start it upon HA start with automation, the 60 seconds change was indeed changed like a year ago…

hikvision_stream_sensor: nohup python3 /config/python_scripts/hikvision_stream.py $1 > /dev/null 2>&1 &

1 Like

Yeah, that was was i was doing before as well.
It’s still the best way for neverending (service-like) scripts