Skip to main content
Question

Auto change of time according to timezone

  • May 29, 2023
  • 2 replies
  • 34 views

Forum|alt.badge.img+5
  • Contributor
  • 64 replies

Guys,

We have a requirements that customer would like want to get the change time change automatically as soon as end user travelled to some other location or region. Kindly help me with the shell script it would be much appreciated. Thanks.

2 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • May 29, 2023

@sk25 You need to have Location Services and automatically set time zone enabled on a Mac for it to automatically adjust time. The following script will set that up (you'll want to restart the Mac to ensure the changes take effect):

#!/bin/sh 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 /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 exit 0

 


Forum|alt.badge.img+1
  • New Contributor
  • 6 replies
  • July 25, 2023

@sdagley for information, you can use the following commands to take changes into account immediately

/bin/launchctl kickstart -k system/com.apple.locationd
/bin/launchctl kickstart -k system/com.apple.timed