Hi all,
I have a condition from time to time where I need to recycle my OpenHAB docker container to reset that condition. I found that there is a command killall5
which is located in /sbin/killall5
that initiates the recycle of the docker container:
root@openhab-2:/openhab# ls -l /sbin/killall5
-rwxr-xr-x 1 root root 23224 Feb 12 2017 /sbin/killall5
root@openhab-2:/openhab#
killall5
is executable for all users! I can run it from command line as user root
and user openhab
and the container stops … (and restarts automatically)
I have created a test rule (see below) to initiate the recycle by a rule.
It seems to execute the command but it does not bring down the container.
Does anyone have any advice what I am doing wrong?
rule "Do what I want"
when
Item test changed
then
logInfo("FILE", "***** Entering: DO WHAT I WANT: " + test.state)
logInfo("FILE", "***** BEFORE ... ")
var results = executeCommandLine("/sbin/killall5", 5000)
logInfo("FILE", "***** RESULT: >" + results + "< *****")
// executeCommandLine("/sbin/killall5")
logInfo("FILE", "***** AFTER ... ")
end
I have also set the following debug level in Karaf log:
log:set debug org.eclipse.smarthome.io.net.exec
because as you can see from the log there is no output from results
:
19:35:20.975 [INFO ] [smarthome.event.ItemStateChangedEvent] - test changed from 1 to 2
19:35:21.010 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** Entering: DO WHAT I WANT: 2
19:35:21.012 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** BEFORE ...
19:35:21.034 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/sbin/killall5'
19:35:21.086 [DEBUG] [clipse.smarthome.io.net.exec.ExecUtil] - exit code '0', result ''
19:35:21.088 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** RESULT: >< *****
19:35:21.089 [INFO ] [g.eclipse.smarthome.model.script.FILE] - ***** AFTER ...
I would expect that killall5
immediately kills the system like it does, when run from command line …
EDIT: The log output shows that the command is actually executed but the explanation below shows why the command does not have any effect. So the problem was not that the command is not executed correctly but that the command did not have the expected result!!!
But the solution to my problem that I like to stop the system was achieved by leveraging a different command as shown below!!!