1

I want to reset the hardware clock from the system clock at shutdown. I created this script (K99savetime.sh):

#! /bin/sh
### BEGIN INIT INFO
# Provides:         savetime.sh
# Default-Start:    6 0
# Short-Description: set hwclock.
# Description:  set hwclock to systemclock on halt or reboot.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

log_action_msg "Updating hwclock with system clock"
hwclock --systohc
exit 0

I saved the script to /init.d, made it executable, and created a symbolic link in /etc/rc6.d

The machine appears to shutdown correctly, that is, I don't see any errors and it doesn't hang up.

  1. How do I know that the script runs at shutdown?

  2. Is the script correctly written to do what I want?

4
  • do not know the script is written is correctly ...but some one who's posting the answer.. the might help ubuntuforums.org/showthread.php?t=185261
    – Qasim
    May 8, 2013 at 23:55
  • The link led met to a greater understanding. Still don't know if it works! May 9, 2013 at 23:41
  • make your script executable...then sh your-script < if it work then it will work on shutdown
    – Qasim
    May 9, 2013 at 23:49
  • To make the script run at both shutdown and restart symbolic links must be created in both /etc/rc0.d and /etc/rc6.d. The link file should be the same name as the script but with S10 prepended to the script name so that it will run early. I used "touch" to create a file just before the hwclock command and just after. It appears to work but I don't understand all the options available in the INIT secton of the script. May 10, 2013 at 19:07

1 Answer 1

1

To make the script run at both shutdown and restart symbolic links must be created in both /etc/rc0.d and /etc/rc6.d. The link file should be the same name as the script but with S10 prepended to the script name so that it will run early. I used "touch" to create a file just before the hwclock command and just after. It appears to work but I don't understand all the options available in the INIT section of the script. –

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .