[Solved] How to restart or shutdown openHAB

I’m running openHABian on raspi. Is there a way to restart the process without rebooting the system?
$ sudo service openhab restart doesn’t work

sudo systemctl restart openhab.service?

How did you start OpenHAB? Is it enabled as a service? Is it listed in the output of service --status-all

I start it by running start.sh in /usr/share/openhab2
When I try $ sudo service openhab stop I get the error “service not found”

That suggests that it isn’t installed as a service.

Depending on your Linux distro, the steps required to configure openhab2 as a service may vary. Were there any messages on install?

On Raspbian, the messages output were

### NOT starting on installation, please execute the following statements to configure openHAB to start automatically using systemd
 sudo /bin/systemctl daemon-reload
 sudo /bin/systemctl enable openhab2.service
### You can start openhab2 by executing
 sudo /bin/systemctl start openhab2.service

(Strange highlighting thanks to the BBS, not intended)

If you run it by manually starting the script, you will need to kill the process.

The service name should be openhab2.

Sounds like it’s not installed as a service, you can install the systemctl scripts manually or you can simply kill the pid. You can find the pid with:

ps ef |grep java

then

kill {pid}

To shutdown gradefully and:

kill -9 {pid)

To just kill without shutdown.

Installed openhab2 as a service. Now it works :+1:Thanks to all who helped.

1 Like

question: a lot of the ways described above do not seem to be concerned with shutting openHab down gracefully. Is that a consideration?

I believe that only kill -9 stops the process immediately. Other methods described above should do it gracefully. There was an old topic where people discussed how to stop openhab gracefully, though I didnt find the answer for my question there Best way to gracefully stop a (running slight_smile ) OH2 server I, personally, was looking for any method to restart OH whithout rebooting the system.

Have you tried pkill ?

So for someone who has just used the OpenHABianPi image, what is the ideal way to shut down just openhab and then restart it again?

1 Like

You mean http://docs.openhab.org/installation/linux.html#service-control ?

1 Like

Possibly… But for Linux novice it’s not easy to know which is the correct one. I’ll try different the different options and report back.

UPDATE : It looks like the section titled “Linux init systems based on systemd (e.g. Debian 8, Ubuntu 15.x, Raspbian Jessie and newer):” on that page is the one to use…

Yup :slight_smile:

It is not instantly clear from the current version of the documentation. So I’ll put it here for reference:

sudo systemctl restart openhab2.service
1 Like

systemctl restart openhab2.service

works for me. Note the “2”

I just Sudo reboot.
Is this bad… :grimacing:
Pi back up and running and openhab fully loaded in about 1 min

i use reboot also hhh
guess not good

thats an old topic but in case someone stumble on that thread like me. I have Gentoo which I use rc-update script. Whatever you are using, you can use the same command to start/stop gracefully and it doesn’T involve killing openhab

To start as a daemon “/opt/openhab2/start.sh daemon”
To stop a running instance “/opt/openhab2/start.sh stop”

Replace /opt/openhab2 with the root path of your openhab folder and you’re good to go