Click to See Complete Forum and Search --> : change time from command line?


spreelanka
04-06-2003, 08:29 PM
hey, my system sync's with a ntp server upon bootup, but even though it's a laptop that doesn't happen so often.
anyway, how do i change the kernel time from the command line? so i can tell cron to do it every once in a while. even better, is there a way that i can just have it sync with an ntp server without grepping+ changing time format + other stuff that would probably be fun but might not work?
thanks in advance

Hayl
04-06-2003, 08:37 PM
you could put this in your /etc/cron.hourly
#! /bin/sh

/usr/sbin/ntpdate -u -b -s swisstime.ethz.ch > /dev/null
/sbin/hwclock --systohc > /dev/null

exit 0note: sometimes ntpdate is in /usr/sbin and sometime it is in /usr/bin.

you need root access to set the hardware clock.

spreelanka
04-06-2003, 09:16 PM
thanks!
> /dev/null , that just keeps it from going to stdout right?
cool! 2 for the post of one!

Hayl
04-06-2003, 09:43 PM
Originally posted by spreelanka
> /dev/null , that just keeps it from going to stdout right?

yep

redcape
04-07-2003, 07:25 PM
If you allow the output to go to stdout you get an email every day telling you how much your clock drifted that day.

Hmm I just realised you are doing it every hour. Hourly emails might be annoying! If you want that level of precision you should probably set up the NTP damon and leave it running all the time.

spreelanka
04-08-2003, 06:30 PM
thanks, i'll look into man ntpdate (or man ntpd, whatever the daemon is) knowing how much my clock drifts everyday might help me eliminate my problem, this system is a laptop and i've heard( and noticed) that the battery level applet slows the clock when it checks the battery level. I haven't found a way to fix this, but to be honest i haven't looked. It isn't crutial for this system but anyone with a fix, lemme know