[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: setting the date for testing



> Could it be that you have systemd-timesyncd running?
> 
> BTW, this is what I do to manually/explicitly set the system time (taken
> verbatim from my vimwiki, so don't mind the wording):
> 
> Changing the Current Date:
> 
> # timedatectl set-time <YYYY-MM-DD>
> 
> Or both at once:
> 
> # timedatectl set-time <YYYY-MM-DD> <HH:MM:SS>
> 
> This commands will fail if an NTP service is enabled. The NTP service can be
> enabled and disabled using a command as follows:
> 
> # timedatectl set-ntp <true|false>
> 
> Changes to the status of chrony or ntpd will not be immediately noticed by
> timedatectl. If changes to the configuration or status of these tools are
> made, enter the following command:
> 
> # systemctl restart systemd-timedated.service
> 
> By default, the system is configured to use UTC. To configure your system to
> maintain the clock in the local time, run the timedatectl command with the
> set-local-rtc option as root:
> 
> # timedatectl set-local-rtc <boolean>

I tried stopping systemd-timedated and ntp:

# systemctl stop systemd-timedated.service
# systemctl stop ntp

Then:

# timedatectl set-time 2025-12-13 14:01:42

and here's what I see by running date every few seconds:

# date
Sat 13 Dec 14:01:43 GMT 2025
# date
Sat 13 Dec 14:01:44 GMT 2025
# date
Sun 13 Dec 14:01:48 GMT 2020
# date
Sun 13 Dec 14:01:49 GMT 2020

I can't see anything running that would re-set the date.

This is a VM running inside virtualbox.  I just figured it out, it WAS
using the hardware clock.  I shut down the VM and ran this on the
host:

VBoxManage modifyvm MyVM --biossystemtimeoffset 126230400000

and now when it booted, I saw this:

$ date
Sun 13 Dec 15:29:47 GMT 2020
$ date
Fri 13 Dec 15:29:59 GMT 2024
$ date
Fri 13 Dec 15:30:00 GMT 2024
$ date
Fri 13 Dec 15:30:01 GMT 2024
$ date
Fri 13 Dec 15:30:01 GMT 2024
$ date
Fri 13 Dec 15:31:49 GMT 2024

and now it appears to stick.  So I'm good.  Thanks for your help though!

Michael Grant

Attachment: signature.asc
Description: PGP signature


Reply to: