<p>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.</p>

<p>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.</p>

<p>How do you ensure that the hardware clock gets updated when you set the system time?</p>

After calling stime(), do this:
```
```
system("/sbin/hwclock --systohc");
```
```
See the hwclock(8) man page for more information.