Hi Wolfgang (@Wolfgang_S ) or any other linux expert,
sorry for pinging you - I remeber you as a linux expert and being very helpful in this forum.
For a couple of days I try to overcome the following problem:
From a rule I want to run a bash script which stops openhab, performs a few maintenance tasks and then starts openhab.
The problem is, when openhab has been stopped, the script stopped, too. Which is somehow explainable and logical. Anyway, I try to find a way that the script “survives” and continues as expected.
Let’s take this as our test.sh script:
#!/usr/bin/bash
systemctl stop openhab.service
echo "Whatever" >> test.txt
systemctl start openhab.service
which gets executed by
actions.Exec.executeCommandLine(time.Duration.ofSeconds(5),"sudo","/etc/openhab/scripts/test.sh");
As said, after command 1, command 2+3 never gets executed (sure, test.sh is added to sudoers).
I tried to start the script in different approaches like
"sudo","test.sh","&"
"sudo","bash","-c","'test.sh'"
"exec,"sudo","test.sh"
but this did not work either.
Do you have an idea?
Plan b would be to create a systemd-timer but I want to pursue this further only if this approach definitely will not work.
During my test I also found out, that openhab starts a dash shell, not a bash shell, in case this makes a difference.