Solved How to keep a jails clock in sync with its hosts clock?

OK I consider myself a pretty savvy jail(8) operator -- or warden, if you prefer.
But I can't for the life of me figure out how to keep the jail' clock synchronized with the host it lives on.
It's a slow creep. But, at this point it's nearly a half a day ahead of the host!

Thank you for all your time, and consideration.

--Chris
 
Why is it out of sync with the host is the better question.
Something is not set right.

Have you set the timezone in the jail?
 
A crude method would be to use ntpdate; although it will give you an error because jails obviously can't control the main (hardware) clock it will also reset your local (kernel) time. Still, maybe timed(8) can be of some help here, not sure from mind.

Reminds me of a Linux date command which explicitly allowed you to control either the hardware clock or that of the underlying OS. To my knowledge FreeBSD doesn't provide that level of control.

Why is it out of sync with the host is the better question. Something is not set right.
It's not that weird. Because both kernel processes (host and jail) will maintain their own clock which means they can also get desynced a bit after a while. I sometimes see the same thing on my setup, yet only for a few seconds at most.
 
I had originally wrote that you could use an ntp server on the host and use a ntp driftfile in the jail.
It just seems so utter ridiculous that a jail could be out of sync. There is no kernel. It is a sandbox.
Something is not set right. My money is on timezone.
 
Why is it out of sync with the host is the better question.
Something is not set right.

Have you set the timezone in the jail?
Right! That was my initial thought as well -- How the **** can the jail be out of sync, when it's a child of the parent?!
But longer thought, brought me to the understanding ShelLuser has already explained.

Thanks, Phishfry , for taking the time to reply!

--Chris
 
A crude method would be to use ntpdate; although it will give you an error because jails obviously can't control the main (hardware) clock it will also reset your local (kernel) time. Still, maybe timed(8) can be of some help here, not sure from mind.
Nope, ntpdate(8) (correctly) spanked me for trying to use it. So yes, you're right. :)
It's odd because one of the first things I do when I initiate a jail, is set location/region, and 2 accounts -- root, and regular user.

Reminds me of a Linux date command which explicitly allowed you to control either the hardware clock or that of the underlying OS.
LOL! That's rich thanks for sharing that! :)
To my knowledge FreeBSD doesn't provide that level of control.
It (rightly) does not. :)


It's not that weird. Because both kernel processes (host and jail) will maintain their own clock which means they can also get desynced a bit after a while. I sometimes see the same thing on my setup, yet only for a few seconds at most.
Well mine has been running for a couple mos. now. So it's gotten w-a-y out of sync. Now at half a day (ahead). I need to figure a way to correct it. Don't you think? ;)

Thanks for taking the time to reply, ShelLuser !

--Chris
 
I had originally wrote that you could use an ntp server on the host and use a ntp driftfile in the jail.
It just seems so utter ridiculous that a jail could be out of sync. There is no kernel. It is a sandbox.
Something is not set right. My money is on timezone.
Nope. My jail(8) initiation steps go as follows:
User setup/password
Locale
(new) aliases
/etc/ tweaks

Note locale (above) ;)

Thanks, Phishfry ! :)

--Chris
 
Please post the exact output of date(1) command on host and in jail. Like date; jexec foo date (assuming your jail is named foo).
Hello, Bobi B. ! Thanks for the reply!

Thanks for the hint! While I didn't execute the command. It did get me to thinking I should take a closer look.
Doing so, indicated thet the jail(8) was UTC, while the host is PDT. See the difference? ;)
Anyway. I have NO idea how I could go from PDT on the jail, to UTC. As I mentioned earlier; I always setup the time/date/locale as part of my jail initiation process -- and I did do that with this one.
A real head scratcher.

Gold star for you, Bobi B. !

Thanks!

--Chris
 
OK problem solved. While not necessarily fixed. The jail(8) is at least in the right timezone -- for now. (See my reply to Bobi B. above).
Now all I need to do, is figure out how things got changed. :-/
This is going to keep me awake nights. :(

Big thanks to Phishfry , ShelLuser , and Bobi B. for all your input, and help!

--Chris
OH, and for those looking on. The easiest way to accomplish this is to execute:

/usr/libexec/bsdconfig/090.timezone/timezone
 
I believe Phishfry is the one to take the credit.

As a hint, if you use sysutils/ezjail, you can preconfigure jails using skeleton dir /usr/jails/newjail. Everything you put in there (/usr/jails/newjail/etc, like resolv.conf and rc.conf) will be copied into new jails you create.
 
I believe Phishfry is the one to take the credit.

As a hint, if you use sysutils/ezjail, you can preconfigure jails using skeleton dir /usr/jails/newjail. Everything you put in there (/usr/jails/newjail/etc, like resolv.conf and rc.conf) will be copied into new jails you create.
True. But then you loose all the flexibility that is inherent in a traditional jail(8). ;)
But to each, their own. Or There's more than one way to do it. :)

Thanks for the thoughtful reply, Bobi B. !

--Chris
 
Back
Top