On Wed, Oct 19, 2022 at 11:20:29PM +0200, Antony Stone wrote:
> On Wednesday 19 October 2022 at 23:16:51, Antony Stone wrote:
>
> > On Wednesday 19 October 2022 at 22:46:54, o1bigtenor via Dng wrote:
> > > How does one set the hardware clock so that it synchronizes with ntp?
> >
> > For me, "/etc/init.d/ntp restart" does the trick (takes a few seconds).
>
> Oh, and I realised you asked specifically about the *hardware* clock - that
> gets done automatically on shutdown.
>
> Do you need to synchronise the *hardware* clock during system run time? I
> can't think of anything which would use that in favour of the kernel clock.
You might want to sync the hardware clock so it's done beforem say, a power failure.
In any case, here's a copy of a web page I downloaded ages ago about time matters.
-- hendrik
---------cut here---------
<!-- CPQLINUX TEMPLATE_HEAD BEGIN - Auto generated, do not edit between matching BEGIN and END sections. -->
<HTML>
<HEAD>
<TITLE>Setting the Date and Time in Linux</TITLE>
<LINK REV="made" HREF="
mailto:richard.black@cpqlinux.com">
<META NAME="author" content="Richard Black">
<META name="keywords" content="linux, Linux, linux, Linux, compaq, Compaq, date, time, timezone, tz, utc, cdt, CDT, cst, CST">
<META name="description" content="Instructions on setting the date, time, and timezone in Linux (and making it stick).">
<LINK REL="stylesheet" TYPE="text/css" HREF="cpqlinux-style.css">
</HEAD>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="generic_background.jpg">
<CENTER><H1>Setting the Date and Time in Linux<BR>
<FONT SIZE=-2>Updated October 10, 2002<BR>
Created September 27, 2000</FONT></H1></CENTER>
<HR>
<A HREF="
http://www.cpqlinux.com/sitemap.html">Autogenerated Site Map</A><BR>
Search this Site!:
<table cellspacing=0 border=0 bgcolor=#a0a0a0>
<tr><td bgcolor=#e0e0e0><font size=1 face="arial,helvetica" >
<A HREF="
http://search.freefind.com/find.html?id=83840291">
Search this site</a>
powered by <A HREF="
http://www.freefind.com">FreeFind</A><br>
</font></td></tr>
<tr><td bgcolor=#a0a0a0><font size=1 face="arial,helvetica" >
<center>
<FORM ACTION="
http://search.freefind.com/find.html" METHOD="GET" target="_self">
<INPUT TYPE="HIDDEN" NAME="id" SIZE="-1" VALUE="83840291">
<INPUT TYPE="HIDDEN" NAME="pid" SIZE="-1" VALUE="r">
<INPUT TYPE="HIDDEN" NAME="mode" SIZE="-1" VALUE="ALL">
<INPUT TYPE="HIDDEN" name="n" value="0">
<INPUT TYPE="TEXT" NAME="query" SIZE="20">
<INPUT TYPE="SUBMIT" VALUE=" Find! ">
<INPUT TYPE="SUBMIT" NAME="sitemap" VALUE="Site Map">
</FORM></center></font></td></tr>
</table>
<HR>
<!-- CPQLINUX TEMPLATE_HEAD END - Auto generated, do not edit between matching BEGIN and END sections. -->
<!--
PLACE_CREATED_DATE_HERE = "September 27, 2000"
PLACE_DESCRIPTION_HERE = "Instructions on setting the date, time, and timezone in Linux (and making it stick)."
PLACE_KEYWORDS_HERE = "linux, Linux, compaq, Compaq, date, time, timezone, tz, utc, cdt, CDT, cst, CST"
PLACE_TITLE_HERE = "Setting the Date and Time in Linux"
-->
<!--
PLACE_NEXT_ITEM_HERE = "fixme"
PLACE_PREVIOUS_ITEM_HERE = "fixme"
-->
You have at least 2 methods for setting the date and time in Linux:
<OL>
<LI>You can set the time by hand, but be careful, lots of clocks tend to drift over time. The trick here to make the time stick across a reboot is to run the hwclock command as shown below</LI>
<BR>
<LI>You can use NTP (Network Time Protocol) to get accurate time from a network time server (Atomic Clock). I highly recommend using NTP to keep your time set correctly: <A HREF="ntp.html">ntp.html</A></LI>
</OL>
<b class="note">Note: Just using the date command alone will not cause the date to remain after a reboot. The date command sets the Linux system clock which is separate from the hardware clock. The "hwclock --utc --systohc" command is used to update the hardware clock with the date from the Linux system clock.</b><BR>
<BR>
Run the date command to make sure you have the correct time:
<BR><BR>
<TABLE class="cpqcode">
<TR><TD>
<PRE>
[root@server /root]# <B>date</B>
Thu Sep 20 11:00:06 CDT 2001
[root@server /root]#
</PRE>
</TD></TR>
</TABLE>
<BR>
If you have the wrong timezone set, use "timeconfig" or "linuxconf" to set the correct timezone.<BR>
<BR>
If your timezone is correct but the date and/or time needs updating, the following commands will update the date and time. The second command is needed in order to push the date and time into the PC clock.
<BR><BR>
<TABLE class="cpqcode">
<TR><TD>
<PRE>
[root@server /root]# <B>date 092011082001</B>
Thu Sep 20 11:08:00 CDT 2001
[root@server /root]# <B>hwclock --utc --systohc</B>
[root@server /root]#
</PRE>
</TD></TR>
</TABLE>
<!-- CPQLINUX TEMPLATE_TAIL BEGIN - Auto generated, do not edit between matching BEGIN and END sections. -->
<HR>
Search this Site!:
<table cellspacing=0 border=0 bgcolor=#a0a0a0>
<tr><td bgcolor=#e0e0e0><font size=1 face="arial,helvetica" >
<A HREF="
http://search.freefind.com/find.html?id=83840291">
Search this site</a>
powered by <A HREF="
http://www.freefind.com">FreeFind</A><br>
</font></td></tr>
<tr><td bgcolor=#a0a0a0><font size=1 face="arial,helvetica" >
<center>
<FORM ACTION="
http://search.freefind.com/find.html" METHOD="GET" target="_self">
<INPUT TYPE="HIDDEN" NAME="id" SIZE="-1" VALUE="83840291">
<INPUT TYPE="HIDDEN" NAME="pid" SIZE="-1" VALUE="r">
<INPUT TYPE="HIDDEN" NAME="mode" SIZE="-1" VALUE="ALL">
<INPUT TYPE="HIDDEN" name="n" value="0">
<INPUT TYPE="TEXT" NAME="query" SIZE="20">
<INPUT TYPE="SUBMIT" VALUE=" Find! ">
<INPUT TYPE="SUBMIT" NAME="sitemap" VALUE="Site Map">
</FORM></center></font></td></tr>
</table>
<HR>
Homepage: <A HREF="
http://www.cpqlinux.com">
http://www.cpqlinux.com</A><BR>
Site Map: <A HREF="
http://www.cpqlinux.com/sitemap.html">
http://www.cpqlinux.com/sitemap.html</A><BR>
<BR><BR><BR><BR><BR>
</BODY>
</HTML>
<!-- CPQLINUX TEMPLATE_TAIL END - Auto generated, do not edit between matching BEGIN and END sections. -->
---------cut here---------