:: Re: [DNG] setting system time
Αρχική Σελίδα
Delete this message
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" > -->%0A>%20%0A>%20You%20have%20at%20least%202%20methods%20for%20setting%20the%20date%20and%20time%20in%20Linux:%0A>%20%0A>%20<OL>%0A>%20<LI>You%20can%20set%20the%20time%20by%20hand,%20but%20be%20careful,%20lots%20of%20clocks%20tend%20to%20drift%20over%20time.%20%20The%20trick%20here%20to%20make%20the%20time%20stick%20across%20a%20reboot%20is%20to%20run%20the%20hwclock%20command%20as%20shown%20below</LI>%0A>%20<BR>%0A>%20<LI>You%20can%20use%20NTP%20(Network%20Time%20Protocol)%20to%20get%20accurate%20time%20from%20a%20network%20time%20server%20(Atomic%20Clock).%20%20I%20highly%20recommend%20using%20NTP%20to%20keep%20your%20time%20set%20correctly:%20<A%20HREF=%22ntp.html%22>ntp.html</A></LI>%0A>%20</OL>%0A>%20%0A>%20%0A>%20<b%20class=%22note%22>Note:%20Just%20using%20the%20date%20command%20alone%20will%20not%20cause%20the%20date%20to%20remain%20after%20a%20reboot.%20%20The%20date%20command%20sets%20the%20Linux%20system%20clock%20which%20is%20separate%20from%20the%20hardware%20clock.%20%20The%20%22hwclock%20--utc%20--systohc%22%20command%20is%20used%20to%20update%20the%20hardware%20clock%20with%20the%20date%20from%20the%20Linux%20system%20clock.</b><BR>%0A>%20<BR>%0A>%20%0A>%20%0A>%20Run%20the%20date%20command%20to%20make%20sure%20you%20have%20the%20correct%20time:%0A>%20<BR><BR>%0A>%20<TABLE%20class=%22cpqcode%22>%0A>%20<TR><TD>%0A>%20<PRE>%0A>%20%0A>%20%5Broot@server%20/root%5D#%20<B>date</B>%0A>%20Thu%20Sep%2020%2011:00:06%20CDT%202001%0A>%20%5Broot@server%20/root%5D#%20%0A>%20</PRE>%0A>%20</TD></TR>%0A>%20</TABLE>%0A>%20<BR>%0A>%20If%20you%20have%20the%20wrong%20timezone%20set,%20use%20%22timeconfig%22%20or%20%22linuxconf%22%20to%20set%20the%20correct%20timezone.<BR>%0A>%20<BR>%0A>%20If%20your%20timezone%20is%20correct%20but%20the%20date%20and/or%20time%20needs%20updating,%20the%20following%20commands%20will%20update%20the%20date%20and%20time.%20%20The%20second%20command%20is%20needed%20in%20order%20to%20push%20the%20date%20and%20time%20into%20the%20PC%20clock.%0A>%20<BR><BR>%0A>%20<TABLE%20class=%22cpqcode%22>%0A>%20<TR><TD>%0A>%20<PRE>%0A>%20%0A>%20%5Broot@server%20/root%5D#%20<B>date%20092011082001</B>%0A>%20Thu%20Sep%2020%2011:08:00%20CDT%202001%0A>%20%5Broot@server%20/root%5D#%20<B>hwclock%20--utc%20--systohc</B>%0A>%20%5Broot@server%20/root%5D#%20%0A>%20</PRE>%0A>%20</TD></TR>%0A>%20</TABLE>%0A>%20%0A>%20%0A>%20<HR>%0A>%20Search%20this%20Site!:%0A>%20%0A>%20<table%20cellspacing=0%20border=0%20bgcolor=#a0a0a0>%0A>%20<tr><td%20bgcolor=#e0e0e0><font%20size=1%20face=%22arial,helvetica%22%20>%0A>%20<A%20HREF=%22http://search.freefind.com/find.html?id=83840291%22>%0A>%20Search%20this%20site</a>%0A>%20powered%20by%20<A%20HREF=%22http://www.freefind.com%22>FreeFind</A><br>%0A>%20</font></td></tr>%0A>%20<tr><td%20bgcolor=#a0a0a0><font%20size=1%20face=%22arial,helvetica%22%20>%0A>%20<center>%0A>%20<FORM%20ACTION=%22http://search.freefind.com/find.html%22%20METHOD=%22GET%22%20target=%22_self%22>%0A>%20<INPUT%20TYPE=%22HIDDEN%22%20NAME=%22id%22%20SIZE=%22-1%22%20VALUE=%2283840291%22>%0A>%20<INPUT%20TYPE=%22HIDDEN%22%20NAME=%22pid%22%20SIZE=%22-1%22%20VALUE=%22r%22>%0A>%20<INPUT%20TYPE=%22HIDDEN%22%20NAME=%22mode%22%20SIZE=%22-1%22%20VALUE=%22ALL%22>%0A>%20<INPUT%20TYPE=%22HIDDEN%22%20name=%22n%22%20value=%220%22>%0A>%20<INPUT%20TYPE=%22TEXT%22%20NAME=%22query%22%20SIZE=%2220%22>%0A>%20<INPUT%20TYPE=%22SUBMIT%22%20VALUE=%22%20Find!%20%22>%0A>%20<INPUT%20TYPE=%22SUBMIT%22%20NAME=%22sitemap%22%20VALUE=%22Site%20Map%22>%0A>%20</FORM></center></font></td></tr>%0A>%20</table>%0A>%20<HR>%0A>%20Homepage:%20<A%20HREF=%22http://www.cpqlinux.com%22>http://www.cpqlinux.com</A><BR>%0A>%20Site%20Map:%20<A%20HREF=%22http://www.cpqlinux.com/sitemap.html%22>http://www.cpqlinux.com/sitemap.html</A><BR>%0A>%20%0A>%20<BR><BR><BR><BR><BR>%0A>%20%0A>%20</BODY>%0A>%20</HTML>%0A>%20%0A>%20%0A>%20---------cut%20here---------%0A>%20">Reply to this message
Συντάκτης: Hendrik Boom
Ημερομηνία:  
Προς: dng
Αντικείμενο: Re: [DNG] setting system time
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---------