Problem with Exec Binding

Hi !

I had an idea to have a simple rule, which can restart Openhab service and can restart + delete all logs in openhab folder, so I wrote:

rule "Restart_Logs"
Item Restart_Logs changed from OFF to ON
sendCommand(Restart_Logs, OFF)
executeCommandLine(‘sudo /bin/rm /var/log/openhab/*’)
executeCommandLine(‘sudo service openhab restart’)

I have similar function just to restart process and it works well. Problem is with rm. When I put it in shell "sudo /bin/rm /var/log/openhab/* all logs were deleted. Also I notices when I put exect file name which I want to remove, ie.

executeCommandLine(‘sudo /bin/rm /var/log/openhab/satel.log’)

it also works.
So probably there is a problem with *, so is it any other way to refer to all files and let Openhab execute it ?

I have also no problems with persmissions.

Interpreting wild cards is usually something that is handled by the shell. When openHAB is started it is directly started by upstart or systemd (depending on your OS) without an underlying shell. Furthermore the openhab user doesn’t have a shell. So, in short, there is no shell there to interpret the wild card for you.

If I’m correct (this is a working hypothesis, not a known fact) then you might be able to get it to work if you run your command in a shell, something along the lines of:

"/bin/bash -C 'sudo /bin/rm /var/log/openhab/*'"

I tried diff combinations, but it did not work