Save system time to RTC on shutdown - #91
Open
herrfrei wants to merge 1 commit into
Open
Conversation
**Problem:** Currently, `tc-config` reads the RTC on boot, but `rc.shutdown` never writes the system time back to the RTC on shutdown. As a result, any time drift or NTP-based correction made during the session is lost, and the hardware clock gradually becomes stale across reboots. **Fix:** Added a step in `etc/init.d/rc.shutdown` that writes the current system time back to the RTC via `hwclock -w`, mirroring the boot-time logic in `tc-config`: - Respects the `nortc` boot code — RTC write is skipped entirely if RTC handling was disabled at boot. - Respects the `noutc` boot code — uses `hwclock -l -w` (local time) if set, otherwise `hwclock -u -w` (UTC), consistent with how the clock was read at boot.
Collaborator
|
If you are running ntpd (Or chrony), then the kernel should be doing this automatically every 11 minutes. If you are not running ntpd, then you should script this to update the clock when you set the system time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Currently,
tc-configreads the RTC on boot, butrc.shutdownnever writes the system time back to the RTC on shutdown. As a result, any time drift or NTP-based correction made during the session is lost, and the hardware clock gradually becomes stale across reboots.Fix:
Added a step in
etc/init.d/rc.shutdownthat writes the current system time back to the RTC viahwclock -w, mirroring the boot-time logic intc-config:nortcboot code — RTC write is skipped entirely if RTC handling was disabled at boot.noutcboot code — useshwclock -l -w(local time) if set, otherwisehwclock -u -w(UTC), consistent with how the clock was read at boot.