Exec binding to restart OpenHAB

I’am trying to implement a button on the OpenHAB UI to restart OpenHAB. I’ve tried several exec statements, but OpenHAB doesn’t start again after shutting down. I’ve also tried this command line with no success:

nohup /etc/init.d/openhab restart > /dev/null &

Is it possible to do this somehow?

Assuming you are on a RasPi running wheezy or any other system that uses Upstart (e.g. Ubuntu 14) the command would be:

sudo service openhab restart

Assuming you are on a RasPi running jessie or any other system that uses systemd (e.g. Ubuntu 15) the command would be:

sudo systemctl restart openhab.service

Note in both cases you have to use sudo which requires a password so you should configure your sudoers to not require the openhab user to require a password when running systemctl (probably not the best security decision but it could be worse).

1 Like

Thanks, that command worked! But I also had to add the user to “sudo visudo” so no password is needed:

openhab ALL=(ALL) NOPASSWD: ALL
2 Likes