Skip to content

Commit

Permalink
[clock] sync os time to CMOS before rebooting (sonic-net#465)
Browse files Browse the repository at this point in the history
So if CMOS clock has drifted, we fix it at reboot time after syncing
with NTP.

Signed-off-by: Ying Xie <[email protected]>
  • Loading branch information
yxieca authored Feb 19, 2019
1 parent 8b6aea1 commit 5b62831
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ sync
sleep 1
sync
# sync the current system time to CMOS
if [ -x /sbin/hwclock ]; then
/sbin/hwclock -w || /bin/true
fi
# Reboot: explicity call Linux native reboot under sbin
debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..."
exec ${REBOOT_METHOD}
Expand Down
5 changes: 5 additions & 0 deletions scripts/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ echo "User issued 'reboot' command [User: ${REBOOT_USER}, Time: ${REBOOT_TIME}]"
sync
sleep 3

# sync the current system time to CMOS
if [ -x /sbin/hwclock ]; then
/sbin/hwclock -w || /bin/true
fi

if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
echo "Rebooting with platform ${PLATFORM} specific tool ..."
exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} $@
Expand Down

0 comments on commit 5b62831

Please sign in to comment.