Linux provides the stime(2) call to set the system time. However, while this will update the system's time, it does not set the BIOS hardware clock to match the new system time.
Linux systems typically sync the hardware clock with the system time at shutdown and at periodic intervals. However, if the machine gets power-cycled before one of these automatic syncs, the time will be incorrect when the machine restarts.
How do you ensure that the hardware clock gets updated when you set the system time?
I would start by reading the source code of hwclock.
Check out the rtc man-page for details, but if you are logged in as root, something like this:
I would also like to point out the hardware clock is only accurate to a point (I have seen systems that will loose/gain a couple of seconds a day).
Have you considered setting up the network time daemon to sync your clock against a time server?
Admittedly this syncing does not happen until after the daemon starts so keeping your hardware clock in sync also helps between the power up and the point the time daemon syncs against the time server.
After calling stime(), do this:
See the hwclock(8) man page for more information.
If the text editor is different than kubuntu (kate is the default in editor), use your own with the
sudo
command in terminal.sudo kate /etc/default/rcS
press EnterUTC=yes
toUTC=no