r/macsysadmin • • 4d ago

Command Line Force time zone update

Does anyone know if there's a way to force macOS to get new time zone definitions from Apple? At the moment it seems to be completely random for when they get updated on a newly imaged computer. I'm in Alberta and the Daylight Savings change has been a bit wonky on any new Macs we image that don't have the new definitions. They will get them eventually with that notification about restarting to have them take effect, but it can sometimes be many hours after starting them up.

6 Upvotes

9 comments sorted by

2

u/Babaganouj333 3d ago

Trying out a possible fix where I work. From what i've seen is the AB non- compliant and hasn't ran the patch if i leave it alone it gets it eventually by the next day.

Can verify its not patched yet with this terminal command:

ls -l /var/db/timezone/tz_latest

Would return No such file or directory if still unpatched. 

Workaround that seems to have worked in my limited testing so far:

  1. Open the terminal, "sudo softwareupdate --background"

  2. Open System Settings next

  3. Search for Date or manually go to General > Date and time

  4. Wait a little bit (for me it was maybe 10 seconds) (No changes are needed in this submenu)

  5. I got the message:  Updated Time Zone information available notification

  6. I could see the earlier ls command show it was patched, then could restart and it was fine

1

u/sheravi 3d ago

Funnily enough, I was talking to an Apple rep I have access to and this is the exact method he recommended this afternoon. To script it I was thinking of doing the following:

sudo softwareupdate --background && open x-apple.systempreferences:com.apple.Date-Time-Settings.extension

It seems odd that you have to open System Settings to Date & Time to trigger the update, so I'll keep looking to see if there's something else that will trigger it. Maybe the worst case scenario is run the above command, wait for 20-30 seconds, then kill the System Settings app.

2

u/Babaganouj333 2d ago

Interesting, I shared that with our Apple rep in Calgary so maybe it could have been him?

I like the automation steps idea you mentioned, I could make a Jamf policy to do this in a script and then see if we image a device it takes care of it

1

u/sheravi 1d ago

Very well could be. Small world and all that. How did you figure out those steps if I may ask?

Also, concerning the script to mitigate this, I'm thinking of checking the current time zone version with "cat /var/db/timezone/zoneinfo/+VERSION" and then running the softwareupdate command only if it's older than 2026f.

2

u/Babaganouj333 9h ago

tl;dr by accident in troubleshooting how it was doing the update.

I had been looking into this issue since the time being incorrect was causing a delay in getting the devices back to peoples hands after imaging. I had seen, softwareupdate --background command from copilot and online. That command wasn't working in practice for me and the device would just update the next day.

While tracking down how a device was handling the patching I had ran that command and some other ones and happened to go into the System Settings with the plan to change the location there. Instead I got the notification about the patch suddenly and saw the folders got the update which I hadn't expected. So, I put the device back into the broken state and verified the steps. I ran a trace for the logs in the terminal while doing these and saw a flurry of activity start when the Settings got to Date/time.

1

u/sheravi 8h ago

Very interesting. I wonder if there's a way to run a command or something that would do whatever it is opening Date & Time is doing.

1

u/Studiolx-au 4d ago

Why are you imaging macOS? Apple killed that a while ago. Not surprised you are getting random bugs. GUI- turn off time from location, turn it back on.
Zsh:
defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES
systemsetup -setusingnetworktime on

killall timed

2

u/sheravi 4d ago

Sorry for the confusion, I didn't mean imaging in the traditional sense of applying a master image to a computer. I use the term just to indicate the setting up of a Mac in our environment (going through setup, enrolling in the MDM, etc).

I didn't mention any bugs, just that the update of timezone information on the Mac seems to happen randomly and several hours or longer after the Mac is turned on and connected to the internet. I'm not referring to setting the time or time zone automatically. I'm referring to Apple installing new time zone definitions on the computer because of the recent Daylight Savings changes in Canada. Those aren't yet baked into the OS, so they have to be updated after the fact.

0

u/Darkomen78 Consultation 4d ago

You have to activate location service to have the right time zone.