Run time server at bootup?

Ask questions regarding Gentoox, Gentoo and Linux in general in these forums and we'll do our best to help you!
Post Reply
MountainSlide
Linux User
Posts: 18
Joined: Mon Aug 11, 2003 12:35 pm
Location: North Carolina, USA

Run time server at bootup?

Post by MountainSlide »

Hi ShALLaX,

Love the new look and it's so much faster!

My question is how would I set up Gentoox to automatically run a time server at bootup? Often the time is wrong and I don't notice it until too late. I just did an update and then realized that the date and time were wrong.

TIA,
Ron
kvandivo
Newbie
Posts: 9
Joined: Sun Aug 17, 2003 2:08 am

Re: Run time server at bootup?

Post by kvandivo »

MountainSlide wrote:Hi ShALLaX,

Love the new look and it's so much faster!

My question is how would I set up Gentoox to automatically run a time server at bootup? Often the time is wrong and I don't notice it until too late. I just did an update and then realized that the date and time were wrong.

TIA,
i assume when you say "time server" you mean "daemon to make sure I always have the
correct time". A time server is a much different beast.

emerge ntp
modify /etc/ntp.conf and /etc/conf.d/ntpd
rc-update add ntpd default
and if you want to start it running before reboot
/etc/init.d/ntpd start
MountainSlide
Linux User
Posts: 18
Joined: Mon Aug 11, 2003 12:35 pm
Location: North Carolina, USA

Post by MountainSlide »

Thanks, kvandivo. You are correct in your assumption; I did mean to access a time server to have the correct time.
Ron
kvandivo
Newbie
Posts: 9
Joined: Sun Aug 17, 2003 2:08 am

Re: Run time server at bootup?

Post by kvandivo »

kvandivo wrote:
MountainSlide wrote:Hi ShALLaX,

Love the new look and it's so much faster!

My question is how would I set up Gentoox to automatically run a time server at bootup? Often the time is wrong and I don't notice it until too late. I just did an update and then realized that the date and time were wrong.

TIA,
i assume when you say "time server" you mean "daemon to make sure I always have the
correct time". A time server is a much different beast.

emerge ntp
modify /etc/ntp.conf and /etc/conf.d/ntpd
rc-update add ntpd default
and if you want to start it running before reboot
/etc/init.d/ntpd start
I've been asked to touch upon how to modify /etc/ntp.conf and /etc/conf.d/ntpd. I'll do it here so that >1 might possibly be able to benefit from it.

So, I'm going to briefly show pertinent lines in mine.. I'm not saying they are the best,
but they work for me. when you emerge ntp it should tell you where you can get some sample files also.

First, you need to go to
http://www.eecis.udel.edu/~mills/ntp/servers.html
and find a couple of names of servers that are close to you, geographically speaking.
Let's say that these servers are first.server.com, second.server.com and third.server.com.

So,

/etc/ntp.conf:

restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server first.server.com
server second.server.com
server third.server.com
driftfile /etc/ntp.drift
logfile /var/log/ntp.log



/etc/conf.d/ntpd (only showing non comment lines):

NTPDATE_WARN="y"

NTPDATE_CMD="ntpdate"

NTPDATE_OPTS="-b first.server.com"



Change all instances of first, second, and third to match your servers.
Last edited by kvandivo on Tue Aug 19, 2003 3:50 am, edited 1 time in total.
MountainSlide
Linux User
Posts: 18
Joined: Mon Aug 11, 2003 12:35 pm
Location: North Carolina, USA

Post by MountainSlide »

Thanks, kvandivo, for the second reply. I did get it working last night by making changes to the /etc/conf.d/ntpd re NTPDATE but was not sure what to change in the /etc/ntp.conf file. Thanks again,
Ron
kvandivo
Newbie
Posts: 9
Joined: Sun Aug 17, 2003 2:08 am

Post by kvandivo »

MountainSlide wrote:Thanks, kvandivo, for the second reply. I did get it working last night by making changes to the /etc/conf.d/ntpd re NTPDATE but was not sure what to change in the /etc/ntp.conf file. Thanks again,
Just to give a wee bit of background on the two files..

/etc/conf.d/ntpd affects the ntpdate command that gets run when /etc/init.d/ntpd is first executed. This let's you have a correct time immediately. For the most part, that's what /etc/conf.d/ntpd does.

But, once you actually have ntp running, it uses /etc/ntp.conf from that point. So, it is vital that both are set if you want your time to actually _stay_ correct.

I had a server that was running for days on end and I was noticing that the time was drifting a few seconds from day to day. If i restarted the ntp service, everything magically corrected itself and, come to find out, I had modified /etc/conf.d/ntpd but hadn't set /etc/ntp.conf up, so it was working great when the service actually started, but wasn't keeping time after that.

HTH,

K
rocketeer
Pro
Posts: 75
Joined: Sun Aug 17, 2003 12:05 am

Post by rocketeer »

While we're at it, setting the TZ variable reflecting your time zone is convenient when doing date, ls etc. As an example, I live in Sweden (CET, UTC +1h) and adjust time in summer (CEST, UTC +2h):

Code: Select all

export TZ=CET-1CEST-2,M3.5.0/2,M10.5.0/3
Post Reply