openhab2 Startup script raspberry pi version not working

Hi all

I tried to get the raspberry version of the start up script running as it was descriped here:

systemctl enable works without errors - but while executing the systemctl start command I’m getting the following error:
Failed to start openhab.service: Unknown unit: openhab.service

Any ideas?

Did you sudo systemctl daemon-reload ?

If this does not help, what is the output of ls -l /lib/systemd/system/ ? Are there differences in mod/owner:group between other services and openhab.service?

systemctl list-unit-files should show up a long list of services and openhab.service should appear in this list.

1 Like

Hi Udo,
thanks for your hints.

I have checked:

  • runned the reload command once again
  • no difference in the mod/owner group
  • openhab appears in the long list

but still the issues remains ;(

Any further ideas?

Are you sure that you have no typo in the filename or in the file itself? did you set the correct path to

We’ve had this topic a few times… it seems like the installer does not work for arm devices. i.e. the pi. find my thread, kai mentioned the link to a way how to self-write a init.d script instead.

It must be something else - even when the file openhab.service is empty/not there I get the same message… It must be in /lib/systemd/system, right?

@Bernd: can you please share your init.d script? Thanks!

Ok, here is a quick howto about init.d scripts:

But be aware that you need to register the service as described or the service dies when you close the console…


# Provides: openhab2
# Required-Start: $localfs $syslog $remote_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: openhab2 daemon
# Description: openhab2 init.d script

 # simple init for openhab2


 case "$1" in
        chrt 50 /opt/openhab2/ | perl -ne '$|=1; print localtime . ": [openhab2] $_"' >> /var/log/openhab2.log &
        echo "Error: argument '$1' not supported" >&2
        exit 3
        killall openhab2
        if [ ! -e $pidfile ]; then
                echo "No pid"
                exit 1
        pid=`cat $pidfile`
        if kill -0 $pid &>1 > /dev/null; then
                echo "Running"
                exit 0
                rm $pidfile
                echo "Not running"
                exit 1

        echo "Usage: openhab2 [start|stop|status]" >&2
        exit 3


Well, imho it would be worth to evaluate, why systemd isn’t working properly in this case. Regarding my own devices all hitches with systemd I saw turned out to be typos or insufficient user rights

@mm1804 please show output of ls -l /etc/systemd/system/

here you go:

lrwxrwxrwx 1 root root 40 Nov 7 09:50 avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service lrwxrwxrwx 1 root root 37 Jul 24 2015 cgmanager.service -> /lib/systemd/system/cgmanager.service lrwxrwxrwx 1 root root 35 Jul 24 2015 cgproxy.service -> /lib/systemd/system/cgproxy.service lrwxrwxrwx 1 root root 38 Feb 27 21:57 networking.service -> /lib/systemd/system/networking.service lrwxrwxrwx 1 root root 36 Feb 27 22:14 openhab2.service -> /lib/systemd/system/openhab2.service lrwxrwxrwx 1 root root 38 Sep 10 22:24 postgresql.service -> /lib/systemd/system/postgresql.service lrwxrwxrwx 1 root root 36 Feb 27 21:57 -> /lib/systemd/system/ lrwxrwxrwx 1 root root 35 Aug 20 2015 rsyslog.service -> /lib/systemd/system/rsyslog.service

@bernd: works by the way…thanks!

So it seems that you don’t have any openhab.service at all, but openhab2.service. What’s the content of /lib/systemd/system/openhab2.service?


Description=Starts and stops the openHAB Home Automation Bus

ExecStop=kill -SIGINT $MAINPID


no cuase I stll have a openhab1 instance on hold (not running!)

So if there is a file openhab2.service, you can’t deny it’s obvious that the correct command has to be

systemctl start openhab2.service

Sure, that is the command I used …

Your original post suggests you (incorrectly) used:

systemctl start openhab.service

Instead of:

systemctl start openhab2.service

Jumping in on that thread, because I’m trying to get OH2 started as a service on my raspi, however I’m failing.

I created the file “openhab.service” in /lib/systemd/system/ as discribed in Github-link .
I did the “systemctl enable openhab.service” followed by “systemctl start openhab.service”.
However I can’t connect to it using any UI.
The oberservation I got is that for each “systemctl status openhab.service” to printout states a “(running) since …xs ago”. As if it was start just with this command?
I’m lost!

[code]/etc/init.d $ sudo systemctl status openhab
● openhab.service - Starts and stops the openHAB Home Automation Bus
Loaded: loaded (/lib/systemd/system/openhab.service; disabled)
Active: active (running) since Fri 2016-04-08 22:12:35 CEST; 3s ago
Main PID: 20320 (java)
CGroup: /system.slice/openhab.service
└─20320 /usr/bin/java -Dopenhab.home=/opt/openhab2 -Dopenhab.conf=/opt/openhab2/conf -Dopenhab.runtime…

Apr 08 22:12:35 OpusPi systemd[1]: Starting Starts and stops the openHAB Home Automation Bus…
Apr 08 22:12:35 OpusPi systemd[1]: Started Starts and stops the openHAB Home Automation Bus.
Apr 08 22:12:35 OpusPi[20320]: Launching the openHAB runtime… [/code]

also having some issues with that. START looks like working finde, but STOP don’t to it’s job. So tried some of your advice @Udo_Hartmann.


-rwxrwxrwx 1 root root 362 Apr 9 04:41 openhab.service
lrwxrwxrwx 1 root root 9 Apr 2 21:33 killprocs.service -> /dev/null
lrwxrwxrwx 1 root root 9 Apr 2 21:33 mountkernfs.service -> /dev/null
lrwxrwxrwx 1 root root 9 Apr 2 21:33 mountnfs-bootclean.service -> /dev/null
lrwxrwxrwx 1 root root 9 Apr 2 21:33 mountnfs.service -> /dev/null

I do habe some services pointing to /dev/null … Don’t have any idea if that normal or something is broken by moving the hole system from SD to USB. But since doing that, everything works absolut finde. So maybe that normal?!

tmp.mount                              disabled
mountdevsubfs.service                  masked  
mountkernfs.service                    masked  
mountnfs-bootclean.service             masked  
mountnfs.service                       masked  
openhab.service                        enabled
killprocs.service                      masked
plymouth-halt.service                  static  
plymouth-kexec.service                 static 

openhab.service looking finde. But there are a lot services masked. Also the killprocs.service masked is. Maybe thats something to do with my problem that i can’t kill the openhab.service?

Got myself some help from @DennisausBremen.
I changed the location of the file “openhab.service” from:
"/lib/systemd/system/" to
AND did use “root” as user.

It is working now (GUIs are connecting, Starting a Systemstart).
Did I misunderstand the description on Github ?