Clear the Cache

Often when one encounters a problem with OH, particularly after an update, OH will refuse to run or certain parts of OH stop working. Some reported errors include:

  • 500 or 404 errors when accessing the UIs
  • lots of exceptions from Jetty or other core components in openhab.log
  • OH refuses to start at all

The first step in debugging the problem is to clear the tmp and cache.

Installed OH

If you are running an installed OH (openHABian, installed using apt or yum):

  1. openhab-cli stop

  2. openhab-cli clean-cache

  3. openhab-cli start

  4. Watch openhablog for errors, test if the problems persist. If so, serach the forum and post a new thread if you do not find a solution. To get more information in openhab.log, use openhab-cli start --debug to enable debug logging.

Manual OH Install / Docker

  1. Stop OH if it is running.

  2. Delete the /var/lib/openhab2/cache and /var/lib/openhab2/tmp folders. For manual installations these folders are in your OH home folder under userdata.

  3. Start OH.

  4. Watch openhab.log for errors, test if the problems persist. If so, search the forum and post a new thread if you do not find a solution. Log into the karaf console and enable debug logging to get more information about the errors.

EDIT: Reworked to use openhab-cli for installed OH and to delete the cache and tmp folders, not just their contents.

45 Likes

Hi Rich,

thanks for the Thread.
Could you please help a noob like me with the commands ?

  1. Stop OH
sudo systemctl stop openhab2.service
  1. Delete the contents of /var/lib/openhab2/cache and /var/lib/openhab2/tmp. DO NOT DELETE THE FOLDERS THEMSELVES, JUST THE CONTENTS.
HOW TO DO THIS ? 
  1. Start OH.
cd /etc/init.d
sudo ./openhab2 start

dont want to break OH - Thanks

1 Like

Stop OH / Start OH

Depends on the installation:

for example:
http://docs.openhab.org/installation/linux.html#service
start, restart, stop and retrieve status
sudo systemctl start openhab2.service
sudo systemctl restart openhab2.service
sudo systemctl stop openhab2.service
sudo systemctl status openhab2.service

for example
FTP Client: Log in with FTP Client, delete all subfolders and files from folders above
Samba Mount: Mount Fodlers via Samba (if enabled), delete all subfolders and files from folders above

2 Likes

hi Philipp,

openHABian HowTo
if running OH2 on a Debian like Linux (openHABian being one of those), it’s done like this:

sudo /etc/init.d/openhab2 stop
sudo rm -rf /var/lib/openhab2/cache/*
sudo rm -rf /var/lib/openhab2/tmp/*
sudo /etc/init.d/openhab2 start

note:

  • If you installed OH2 manually (e.g. not with openHABian), the cache and tmp folders are located in another place, but you will know (as then you’re supposedly an expert).
  • if running OH2 in another OS as Debian, the OH2 Service ist stopped and started differently and the folders for cache and tmp are in a different place (again: then you’re supposedly an expert and know how and where),
12 Likes

Thank you!

Is there any information available that explains / documents the bug(s) that require a manual deletion of tmp & cache?

The implications of randomly requiring a manual deletion of tmp & cache are dramatic when trying to automatically update OH as it will sometimes brick it. Deleting the cache & tmp on every update also seems to be troublesome as this requires re-downloading dependencies (bundles) that are stored in cache, which from my experience is also not very reliable and will lead (on first start after deletion) to a fast number of NotFound exceptions, thus forcing a second restart.

1 Like

Is cache the same that is stored in the xml/java database? I had some issues that i had 2 entries for mqtt binding etc… when I checked in the karaf console. Is there a way to clear out all info in that cache/Db so it reloads it from the .cfg .items .rules .things file?

You can search the forum. But whenever there is an error that seems to point to a corruption (e.g. 500 errors, screen saying to wait while UIs are installed never goes away, add-ons refuse to be installed or uninstalled) that corruption would be in the cache and tmp. This is why that is one of the first recommendations for people to try. Their system is already broken, clearing the cache will not make it any worse.

There is even a command line option you can provide to cause karaf to do this on its own every time it starts for you, so it isn’t really that big of a deal. It will lead to longer startup times but shouldn’t cause any further problems. I don’t recommend doing that unless you find that you need to clear the cache every time you restart OH.

Absolutely and positively not. Only Things and Items and such created using PaperUI go in the JSONDB.

The proper solution there is to remove one of them using console commands. See http://docs.openhab.org/administration/index.html

It depends on how you have your system set up. If you have used PaperUI for ANYTHING then you need to tread carefully.

Hey @rlkoshak,

thanks for this input, it helped me getting my avmfritz binding working again!

Question:
After deleting those folder contents, I did notice the following things

  • All my Bindings where gone!
  • All my Actions where gone!
  • All my Persistence items where gone!
  • Misc, Transformations and User Interfaces where still there!

It was not really a big deal but if I had known that something would be missing,
I would have created a short list with the bindings I had installed :slight_smile:.

Do you know if this behaviour is correct in OH 2.2.0, and why?
[Openhabian 1.4 on Raspberry 3]

Best regards,
Marcel

When you clear the cache your add-ons should be reinstalled. If that didn’t happen then that is incorrect behavior but I can’t guess as to why that didn’t happen.

The steps I outline above are part of the standard steps that happen during all upgrades.

1 Like

Hi @rlkoshak, thanks for the tuts, a non cache/tmp question, what is core file? This file located in /userdata root with about 274,552KB size(2.3snapshot #1225), can I also need to delete this core file when upgrading?
image

add1: I’ve deleted this core file and it seems nothing happen, system still running well, so I am confused, what exactly does this core file do and why so large? Thanks

add2: may I also ask you where to find the “changelog” when a snapshot image get pushed? I don’t see any changelog thing on https://openhab.ci.cloudbees.com/ or the docker github page. I can see the #1225 number is growing but how to see what exactly change comparing to prviously number? Thanks

A core file occurs when a program crashes hard work a segfault. I’m surprised to see one here. It is late because it contains everything in ram at the time of the segfault. Had OH ever just inexplicably stopped?

There is no changed log for the snapshot. The snapshot is intended for the devs and for those who are good at debugging problems and consist of the result of the nightly builds. There is no release process beyond the nightly build succeeding. You can watch the prs on the various GitHub repos. Once a PR is merged it becomes party of the nightly build.

Nope, this is a brand new docker pull today, I never happen to see this core file ever, I docker pull the same image on rpi3,2,1 and x86 vm machine, never get that core file thing, and I think OH never accidently stop.
although there is one thing maybe related to this core file, is because I use a brand new sbc called NanoPi Duo to setup this openhab server(screenshot from that server), everything running so good but memory usage is go very high(435 of 512ram + 64 of 621zram, also running 10 containers in background, grafana,influx,mqtt,etc…), not sure if this is causing the core file thing created due to low mem…
so far so good still…

Oh, wow, thank you.
After ugrading to 2.3 on Ubuntu 16.04 LTS , the openhab mqqt binding stopped functioning.
This was critical for my mysensors network.
Clearing the cache refreshed the vital components that fixed the issues
Openhab2 began to react to mqqt inputs and publishing the openhab2 event bus to mqqt broker.

@rlkoshak, reading another (misguided) post, I did not heed your advice here and deleted the folders /var/lib/openhab2/cache and /var/lib/openhab2/tmp, not just their contents. Now my bundles aren’t starting among other issues. Is there any way to fix this without starting over??

just recreate the folders and give them the correct ownership:

(sudo su)
mkdir /var/lib/openahab2/cache
mkdir /var/lib/openahab2/tmp
chown openhab:openhab /var/lib/openahab2/cache
chown openhab:openhab /var/lib/openahab2/tmp
1 Like

Thanks. Actually, it did that automatically with 2.3. However the missing link was that I needed to reinstall the serial transport in the console. Hope this helps someone.

I followed this thread and deleted files in cache and tmp because things were just going bonkers. Now Paper UI is gone, all I have are homebuilder, logviewer, and help. I didn’t have a backup, but I do have the items files, which is where I spent most of my time. What is my best course of action now?

Edit addons.cfg to install PaperUI and your other needed bindings.

Could you elaborate a little more? Stating “edit” means nothing.