OpenHab freezes or crashes after running a few days

Start with cleaning the cache and rebooting to see if that helps.

sudo systemctl stop openhab2

sudo openhab-cli clean-cache

sudo reboot

If the issue remains l would try using a different persistence service as InfluxDB can sometimes be very taxing on memory. If it meets your needs RRD4J works well with the RPI.

Another thing to try is using a new SD card. I know you mentioned the SD should be fine but unplugging the power is never good and will eventually lead to a corrupt SD card. Once that happens troubleshooting/debugging becomes very difficult. If you have a spare SD card I would make a backup, install a fresh image, and restore the backup on the new card.

Also, here’s an interesting topic that may help.