Skip to main content
Question

Time Zone using Current Location scriptable?


Show first post

36 replies

Forum|alt.badge.img+4
  • Contributor
  • 19 replies
  • June 26, 2018

Testing on 10.13.4 I also get the error mentioned by @shan3 .


Forum|alt.badge.img+6

It's a real shame the python code no longer works on 10.13.4 and above. This was a great find, but once again apple broken something useful.

On top of this I have noticed that this code no longer works on 10.13.3/10.13.4 and newer. I'm still looking into it, but no luck. /usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES

this command no longer ticks the option to set time zone automatically using current location


Forum|alt.badge.img+13
  • Honored Contributor
  • 550 replies
  • June 29, 2018

I get the opposite on 10.13.4, The box gets ticked, however the map does not show until I click on another tab


Forum|alt.badge.img+4
  • New Contributor
  • 2 replies
  • July 2, 2018

@ewinterbourne I'm still getting the same problem with that command in 10.13.5, Trying to find a way around it but no joy as of yet.


Forum|alt.badge.img+3
  • New Contributor
  • 9 replies
  • November 12, 2018

I have tried running this script in 10.14.1 and still getting no response from the machine when it comes to ticking the box, under Date & Time. Has anyone been able to find a resolution to this?


Forum|alt.badge.img+7
  • Contributor
  • 91 replies
  • November 13, 2018

@oartola We've been using this https://github.com/jamfprofessionalservices/Jamf-Scripts/blob/master/Set%20Time%20Zone.sh Along with a self service policy.


Forum|alt.badge.img+7
  • Contributor
  • 26 replies
  • January 25, 2019

I'm late to the party on this.

Did anyone ever figure out a fix for @NoahRJ 's script above to work properly in Mojave?

Also, @mack525 your link no longer works.


Forum|alt.badge.img+7
  • Contributor
  • 91 replies
  • January 26, 2019

@DFree It must have been moved. Check out my Github page for the script


Forum|alt.badge.img+10
  • Valued Contributor
  • 158 replies
  • February 21, 2019
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1

I'm using this as part of my enrollment provisioning on DEPNotify. When the user logs in, before DEPNotify launches, the time is PST. I prompt for reboot at the end of my DEPNotify script and after reboot, the location services kicks in and the time zone is automatically set by current location. It can take a few minutes for it to kick in


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • 473 replies
  • May 11, 2021

Create a blank package with the script below (postinstall). Then add it to your prestage enrollment.

#!/bin/bash


## configure ntp server

/bin/cat > /etc/ntp.conf << 'NEW_NTP_CONF'
server time.apple.com
NEW_NTP_CONF

## configure automatic timezone

/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


## Set date and time automatically
/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

### Restart location services daemon (locationd)
/usr/bin/killall locationd

exit 0;     ## Success
exit 1;     ## Failure

Forum|alt.badge.img

Modifying ByHost plist and those under /private/var/db has no effect. It doesn't toggle the checkbox in System Preferences. At least true for High Sierra, Mojave.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings