I am working with a web-based app on an Ubuntu test/development system running in Parallels. At specific dates and times (taken from the system time) some events happen and things are changed in the database. (e.g., a user account is locked, if password was not changed for a certain time, or the status of an object is changed, if a deadline is passed etc.)
To be able to test specific scenarios, I work with snapshots in Parallels to store the state of the system at several key points in time. It can happen that after several months I need to return to a specific point in time to test a specific scenario on the state back then.
My problem is that after restoring the snapshot, the system date is as I want it to be (namely equal to the datetime when the snapshot was taken).
But after several seconds to minutes, the system time changes to some point in time between the real time and the expected (snapshot) time. I have the impression that it is set to the time that has passed relatively. E.g., if I took the snapshot on 2018-02-01 (real time) with the system date of the Ubuntu guest being 2018-01-01 (guest time) and I restore the snapshot on 2018-03-01 (real time), then the Ubuntu guest will eventually be set to 2018-02-01 (guest time) after some minutes.
What I have done so far:
- Switched off Parallels time sync (according to https://kb.parallels.com/113271)
- Uninstalled
ntp
andntpdate
- Disabled
Automatic Date&Time
andAutomatic Timezone
in Ubuntu desktop settings
The problem seems to be related to hwclock
. As an example, I have restored a snapshot from 2018-01-25 (guest time) yesterday, on 2018-05-25 (real time). I executed (immediately after restoring the snapshot):
date ; \
hwclock --show ; \
date -s 2018-01-26 ; \
hwclock --systohc ; \
hwclock --set --date 2018-01-26 ; \
hwclock --show ;
This results in the following output:
Thu Jan 25 18:17:49 CET 2018
2018-03-09 01:01:27.249216+0100
Fri Jan 26 00:00:00 CET 2018
2018-03-09 01:01:27.775701+0100
If I wait some time, the system time will eventually change to the hwclock time - I have not found out why. I also don't understand why the attempts to set the hwclock
time does not work (no error is shown, but the new time is ignored...)
Finally, I also have checked the syslog
but there is no hint about the changed date. It just prints an entry for the old date and the next entry is with the new date, no indication what caused the date change.
What have I missed?
P.S.
This is the output of systemctl | grep time
rtkit-daemon.service loaded active running RealtimeKit Scheduling Policy Service
systemd-timedated.service loaded active running Time & Date Service
timers.target loaded active active Timers
anacron.timer loaded active running Trigger anacron every hour
apt-daily-upgrade.timer loaded active waiting Daily apt upgrade and clean activities
apt-daily.timer loaded active waiting Daily apt download activities
motd-news.timer loaded active elapsed Message of the Day
snapd.refresh.timer loaded active waiting Timer to automatically refresh installed snaps
systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories