起動時にhwclockを自動更新

起動時にhwclockを自動更新

Beagle Bone Blackに小さな問題があります。 RTCバッテリーが付属していないため、電源を切るとハードウェアの時計が台無しになります。起動時にhwclockをシステムクロックと同期させるためのシンプルできれいな方法が必要です。もちろん、システムクロックはntpdから時間を取るので、起動後のシステムクロックは完璧です。私は解決策を探していますが、いくつかのアドバイスといくつかの構文が必要です。

私は考えて追加しようとしました。

/sbin/hwclock --systohc

/etc/init.d/ntp(開始ケースの内部と終了)では、最初はこれが機能しているように見えましたが、今ではいくつかのテストの後には機能しません。何が変わったのかよく分からない。たぶん私はそれがうまくいくと思うかもしれません。

私はhwclock -wがうまく動作することを知っており、起動時にcronジョブに入れるのと同じことができることを知っていますが、可能であればcronを避けることを好みます。他の提案や構文の変更はありますか?

ありがとう

ちなみに、これはDebianにありますが、Ubuntuでも動作するにはこれが必要です。

ベストアンサー1

fake-hwclockプログラムをインストールしてください:

# apt-get install fake-hwclock


fake-hwclock: Save/restore system clock on machines without working RTC hardware

 Some machines don't have a working realtime clock (RTC) unit, or no
 driver for the hardware that does exist. fake-hwclock is a simple set
 of scripts to save the kernel's current clock periodically (including
 at shutdown) and restore it at boot so that the system clock keeps at
 least close to realtime. This will stop some of the problems that may
 be caused by a system believing it has travelled in time back to
 1970, such as needing to perform filesystem checks at every boot.

 On top of this, use of NTP is still recommended to deal with the fake
 clock "drifting" while the hardware is halted or rebooting.

fake-hwclockをインストールした後、コンピュータは起動時に再び1970年だとは思いません。マシンが起動したら、最後の再起動/終了時に作成されたfake-hwclockタイムスタンプに時計を設定します。これは、起動時にネットワークに問題がある場合は、少し正確な時計を持つことができることを意味します。

おすすめ記事