How Do You Programmatically Set the Hardware Clock on Linux?

前端 未结 5 1380
小蘑菇
小蘑菇 2020-12-08 22:50

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

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 23:44

    After calling stime(), do this:

    system("/sbin/hwclock --systohc");
    

    See the hwclock(8) man page for more information.

提交回复
热议问题