Please provide mac script to set time zone automatically based on the current device location. Script to set time zone published in the script repository doesn’t enable ‘set time automatically using current location’ checkbox in the date & time settings.
Setting time zone on Macs based on current locationSolved
1547 Views
Tags
Replies (4)
This script works on my M1 Mac running Big Sur 11.2.3 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#!/bin/bash #enabling location services /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1 uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57) /usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1 #configure automatic timezone /usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES /usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeOnlyEnabled -bool YES /usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool YES /usr/sbin/systemsetup -setusingnetworktime on /usr/sbin/systemsetup -gettimezone /usr/sbin/systemsetup -getnetworktimeserver |
Works fine on my mac running mojave, but only after a device restart though. Thanks for this @esmee!
Doesn’t need a device reboot on my Mac (Big Sur 11.2.3). The checkbox gets automatically checked on running the script from the portal.
Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review
Hey there, @fleur. On testing the script on a few Macs running different OS versions, we can confirm that the script requires a device reboot only for the older OS versions like Mojave.
@esmee We’ll be sure to add this in our sample script repository.
Thank you 🙂
Have a great day!
Chris Wheeler
Hexnode UEM
Save