Solved Wrong time but right timezone

When I enter the date command it returns a time that is 2 hours behind. But when I setup my timezone with tzsetup I do choose the correct timezone. How can I fix this?
 
In Europe it is summertime now, and even in Greenwich the official time is not GMT but BST = GMT+1. In the Netherlands the time is CEST = GMT+2.
 
The point is that it could indicate the hardware clock is set to UTC while the system is not. Or vice versa.
 
Hey everbody. Since this thread isn't solved and I have investigated the same problem but couldn't solve it.
The Situation: I have a PC and a laptop. Both run the exact same FreeBSD 11-RELEASE. On both the CMOS-clock is set to UTC and they run the same timezone configuration.
I live in Norway so my timezone is set to
Code:
setenv TZ Europe/Oslo
in my ~/.tcshrc. My timezone is +1 hour ahead from UTC.
When I type date on my PC ist shows the right time (UTC+1), but on my laptop it shows me UTC-time (-1 hour from my place).
I tried setting the timezone in /etc/login.conf instead of my shell's configuration, which also works fine on my PC, but does nothing on my laptop.
I then remembered that I maybe, during installation on my laptop, choose that my CMOS-clock is set to local time and started investigating...

As I said, the CMOS-clock on both machines is set to UTC. ps aux shows adjkerntz -i runs on my laptop, which is not the case on my PC.
Further is the sysctl machdep.adjkerntz variable on my PC =0 and on my laptop on =-3600 (which is 3600 seconds/24 hours).
I then killed the running adjkerntz -i on my laptop an then changed
Code:
sysctl machdep.adjkerntz=0
machdep.adjkerntz -3600 -> 0

Still that made no difference and my laptop shows the wrong time.
I also couldn't figure out how the adjkerntz -i process gets startet (it's not from cron). I searched through some /etc/rc. files but there where
no differences between my PC and my laptop.
I would really like to understand how timezone and adjkerntz interact and what configuration is differnt when choosing CMOS is set to localtime during install.
Somebody who knows that?
Thanks!
 
I then remembered that I maybe, during installation on my laptop, choose that my CMOS-clock is set to local time and started investigating...
When you choose local time, a file /etc/wall_cmos_clock has been created, to inform the system that your cmos clock is set to local time. To use a cmos clock set to UTC, delete that file.
 
That did it. Clock now showing right time! Thank you.
Removing /etc/wall_cmos_clock SOLVED it for me.
Since the TS fixed it using ntp, I guess this thread can be marked as solved.
 
For anyone wondering where the /etc/wall_cmos_clock is documented, it's right there in the adjkerntz(8) manual page:

Code:
FILES
     /etc/localtime        Current zoneinfo file, see tzsetup(8) and zic(8).
     /etc/wall_cmos_clock  Empty file.  Its presence indicates that the
                           machine's CMOS clock is set to local time, while
                           its absence indicates a UTC CMOS clock.

The adjkerntz -i command gets called quite early during boot by an rc(8) script /etc/rc.d/adjkerntz as also described in the same manual page.
 
This solved my problem.

Code:
FILES
/etc/localtime Current zoneinfo file, see tzsetup(8) and zic(8).
/etc/wall_cmos_clock Empty file. Its presence indicates that the
machine's CMOS clock is set to local time, while
its absence indicates a UTC CMOS clock.

My case: one machine, three systems. Two clock were ok, my FreeBSD wasn't.
I've just created /etc/wall_cmos_clock in etc... done!
 
Back
Top