VM time and date (NTP) incorrect
Scenario
Post start, you find your VM’s time and date is not up to date. Sometimes off by weeks or months.
Common Causes
- Rarely the screensaver inside of the VM turning on can disable time sync.
- The VM can go to sleep if it’s long-running and cause NTP to get out of sync.
- This happens when the
sudo sntp -sS time.apple.comfails inside of the VM post-start. We’ve disabled automatic NTP syncing to support suspended VM states (it causes problems), so our addons will execute thesntpcommand post-start.- Addons log to
/var/log/anka.loginside of the VM and may indicate/log what went wrong.
- Addons log to
Notes about our addons and NTP:
- Our guest addons disable time sync for the VM’s OS settings no matter what.
- Our addons by default communicate with the host to get the date/time and use that for the VM (not using NTP at all) (set as
1)- Our addons can execute the
sntpsync command withtime.apple.comif you setanka config time_syncto2, post boot.
Solution
- Set screensaver to Never.
- Enable “Prevent automatic sleeping when the display is off” under Energy settings.
- You can manually run
sudo sntp -sS time.apple.comin your jobs to ensure macOS is synced properly.