[SOLVED] Log time vs System Time - Mismatch (No Timezone Adjustment)

Anyone know why and how to fix mismatch between System Time and what OH sees?
This causes my CRON jobs to fire at the wrong time…

From Log

2016-11-24 10:00:00.121 [INFO ] [o.m.s.Xmas Tree switch ON rule] - cron has been triggered

From command line:

openhab:/var/log/openhab $ date
Thu 24 Nov 08:07:05 EST 2016

As you can see my CRON job fired properly at what it thought was correct time of 10 am BUT my system time hasn’t even gotten there yet.

Looking at live logs the time difference appears to be exactly 5 hours. OH seems to be using GMT and not my Eastern Time Zone (5 hour difference)

Thanks!

OK, well thats embarrassing, as soon as I posted I managed to solve my own problem (no luck the 2 hours prior of course!) BUT I am leaving it up here in case anyone else has the same problem. Solution for me was to add the line (under the line “Extra arguments passed to Java”)

JAVA_ARGS=-Duser.timezone=America/New_York

in the file:

/etc/default/openhab`

Here is the Wikipedia list of Timezone names:
Time Zone Names

Here is a list that Java appears to recognize (not sure if any differences)
Java Recognized Time Zone Names

All good (for now) in the log times!

3 Likes

Hi @Luvz2Fly,

i 've migrated from OH 1.x to OH 2.0 and after that, the logs (openhab.log and events.log) were with a 1 hour delta…don’t know why…

So i edited those files…after so many tests… i finally edited …/etc/default/openhab2 and also /etc/default/openhab passing args to Java (timezone)

and now my logs are correct (same time as my local system time, command ‘date’ and OH logs are the same)

So --> thanks for your post!

maxplay

3 Likes

This is what I had to do for openHAB 2 to get it to work.

Use this command:

sudo nano /etc/default/openhab2

Enter password if it asks for it.

Change this line:

EXTRA_JAVA_OPTS=""

to this:

EXTRA_JAVA_OPTS="-Duser.timezone=America/New_York"

Then press Crtl+X to close the file, then press Y for Yes to save the changes, and then press Enter to overwrite the existing file.

After that restart the openHAB service:

sudo systemctl restart openhab2

Or do a system reboot:

sudo reboot

I tried to include as much detail as possible, for those who are as new to this as I am, who might stumble across this post. Honestly, I hate command line based interfaces. But it is what it is…

3 Likes

I’m running OH on docker and have the same issue but when looking in the /etc/default folder I don’t see an openhab2 file.

Anyone any idea how to achieve the above with docker?

@martinvw Martin, you are quite knowledgable in docker, do you have any idea how I can EXTRA_JAVA_OPTS value in /etc/default/openhab2 in case of a docker installation as describe by @BigRedBrent ?

I can’t seem to find any openhab2 file in my docker installation

What I did was configuring my host correct and forwarding the Timezone config.

   volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/etc/timezone:/etc/timezone:ro'

Otherwise this could maybe provide some hints: https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes

Thanks, and yes I’m already including them. I pass the following

-v /etc/localtime:/etc/localtime:ro -v /etc/TZ:/etc/TZ:ro -v /usr/share/zoneinfo:/usr/share/zoneinfo:ro

I was also aware of link you shared. The strange thing is all times seem to be correct in the openhab system only the fronttail logging times are 2 hours off.

My system time is just fine,

Fri Apr 26 20:20:52 AEST 2019

Which is different to my console time:

10:21:47.145 [INFO ] [smarthome.event.ItemStateChangedEvent] - AtticPower changed from NULL to OFF

I set the arguments as per the post.

JAVA_ARGS=-Duser.timezone=Australia/Sydney

But for some reason, even after setting the JAVA ARGS and restarting, the console time is still incorrect.