Deleted log files, OH2 fails to start

Yup deleted my openhab.log and events.log entries. Now can’t get to openhabianpi page.

systemctl status openhab2 gives me this:

/home/openhabian# systemctl status openhab2
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
   Active: deactivating (stop) (Result: exit-code) since Mon 2017-08-07 00:43:08 CDT; 969ms ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 5959 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=255)
 Main PID: 5959 (code=exited, status=255);         : 6112 (karaf)
   CGroup: /system.slice/openhab2.service
           └─control
             ├─6112 /bin/bash /usr/share/openhab2/runtime/bin/karaf stop
             ├─6206 /bin/bash /usr/share/openhab2/runtime/bin/karaf stop
             ├─6207 /usr/lib/jvm/zulu-embedded-8-armhf/bin/java -version
             ├─6208 grep -E "([0-9].[0-9]\..*[0-9]).*"
             ├─6209 awk {print substr($3,2,length($3)-2)}
             ├─6210 awk {print substr($1, 3, 3)}
             └─6211 sed -e s;\.;;g

Aug 07 00:43:05 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Aug 07 00:43:05 openHABianPi start.sh[5959]: Launching the openHAB runtime...
Aug 07 00:43:08 openHABianPi start.sh[5959]: /var/log/openhab2/openhab.log (Permission denied)
Aug 07 00:43:08 openHABianPi systemd[1]: openhab2.service: main process exited, code=exited, status=255/n/a
Aug 07 00:43:09 openHABianPi stop[6112]: stop: Ignoring predefined value for KARAF_HOME

and my daemon.log

Aug  7 00:56:42 openHABianPi start.sh[9121]: Launching the openHAB runtime...
Aug  7 00:56:46 openHABianPi start.sh[9121]: /var/log/openhab2/openhab.log (Permission denied)
Aug  7 00:56:46 openHABianPi systemd[1]: openhab2.service: main process exited, code=exited, status=255/n/a
Aug  7 00:56:47 openHABianPi stop[9275]: stop: Ignoring predefined value for KARAF_HOME
Aug  7 00:56:49 openHABianPi stop[9275]: Can't connect to the container. The container is not running.
Aug  7 00:56:49 openHABianPi systemd[1]: openhab2.service: control process exited, code=exited status=1
Aug  7 00:56:49 openHABianPi systemd[1]: Unit openhab2.service entered failed state.
Aug  7 00:56:50 openHABianPi systemd[1]: openhab2.service holdoff time over, scheduling restart.
Aug  7 00:56:50 openHABianPi systemd[1]: Stopping openHAB 2 - empowering the smart home...
Aug  7 00:56:50 openHABianPi systemd[1]: Starting openHAB 2 - empowering the smart home...
Aug  7 00:56:50 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Aug  7 00:56:50 openHABianPi start.sh[9436]: Launching the openHAB runtime...
Aug  7 00:56:53 openHABianPi start.sh[9436]: /var/log/openhab2/openhab.log (Permission denied)
Aug  7 00:56:53 openHABianPi systemd[1]: openhab2.service: main process exited, code=exited, status=255/n/a
Aug  7 00:56:54 openHABianPi stop[9588]: stop: Ignoring predefined value for KARAF_HOME
Aug  7 00:56:57 openHABianPi stop[9588]: Can't connect to the container. The container is not running.
Aug  7 00:56:57 openHABianPi systemd[1]: openhab2.service: control process exited, code=exited status=1
Aug  7 00:56:57 openHABianPi systemd[1]: Unit openhab2.service entered failed state.
Aug  7 00:56:57 openHABianPi systemd[1]: openhab2.service holdoff time over, scheduling restart.
Aug  7 00:56:57 openHABianPi systemd[1]: Stopping openHAB 2 - empowering the smart home...
Aug  7 00:56:57 openHABianPi systemd[1]: Starting openHAB 2 - empowering the smart home...
Aug  7 00:56:57 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Aug  7 00:56:57 openHABianPi start.sh[9752]: Launching the openHAB runtime...

mosquitto is working though.

● mosquitto.service - Mosquitto MQTT Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled)
   Active: active (running) since Mon 2017-08-07 00:40:50 CDT; 24min ago
     Docs: man:mosquitto(8)
           https://mosquitto.org/
 Main PID: 382 (mosquitto)
   CGroup: /system.slice/mosquitto.service
           └─382 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Aug 07 00:40:50 openHABianPi systemd[1]: Starting Mosquitto MQTT Broker...
Aug 07 00:40:50 openHABianPi systemd[1]: Started Mosquitto MQTT Broker.

Not really interested in a fresh install. Is it fixable?
Thanks for your thoughts.

2 Likes

Have you considered creating a new openhab.log and events.log file in the appropriate directory?

sudo su  //switch to root
systemctl stop openhab2  //stop OH2
touch /var/log/openhab2/openhab.log  //create an empty file
touch /var/log/openhab2/events.log  //create an empty file
chown -R openhab:openhab /var/log/openhab2/  //change the ownership of that folder and files to openhab user and openhab group
systemctl start openhab2  // start OH2
tail -f /var/log/openhab2/*.log  //monitor both log files

(disregard comments after //)

By the way: The /var/log/openhab2/ directory should be owned by the openhab user… as a result, the OH2 process should have been able to write new files in there…
did you delete and recreate the directory also? (with other permissions/ownership?)

1 Like

I made new files but I’m sure the permissions are wrong. Thanks all I’ll try a bit later.

@Dim you know your Linux-Fu. I’m was sure it was the permissions (as you suggested) but I followed your instructions start to finish and, VOILA! It’s back Thank you!

1 Like