give this a shot:
#!/bin/sh
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone="America/New_York"
TimeServer="time.apple.com"
############# Pause for network services #############
/bin/sleep 20
#################################################
/usr/sbin/systemsetup -setusingnetworktime off
#Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone
#Set specific time server
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer
# enable location services
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 /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.notbackedup.$uuid LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
# set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
exit 0
While I'm VERY grateful for this - I'm not able to use location services behind the proxy that is run here. It's a healthcare company and nothing can hit the Internet directly. And, until my solution gets approved I'll never have Apple's 17.0.0.0/8 block open so I can't even use location or notification - any of the useful stuff
To further complicate it - our internal time server is 9 minutes off of both Apple and the navel time servers. God only knows why they wouldn't sync with the navy.
I've run the commands for -setnetworktimeserver domain.com (replacing domain.com with our domain)
My question is whether it matters that the checkmark for 'Set date and time automatically' is not checked in the GUI even after running these commands?
Every check through a remote terminal session comes back as if it's set correctly. I'm not sure whether the GUI has to update or can be updated as well
@k3vmo Try asking your network infrastructure group to create a DNS entry for time.apple.com that points to your internal time server so the default time server settings in macOS just work (I used this approach in a previous job where NTP traffic wasn't allowed through the firewall).
A simple /etc/hosts entry pointing old domain to a functional time server IP may work as well. No internet required.
If your internal time server is 9 minutes off from the Apple and Navy clocks (and presumably others) and your Macs sync up to it, that could cause SSL problems with external sites that DO sync up to atomic clocks. I think that would be your first order of business before you sync up to your company's internal server.
I also work in a HIPAA environment and our network admins have blocked all NTP syncing with Apple's servers, however our internal servers ARE synced up to other external atomic clocks. So in order to get my Macs synced up, I have a command added on to our daily inventory collection: ntpdate -u 10.1.5.5
This makes sure that there is very little time drift at all on a daily basis. The only Macs that end up drifting are those used by people who go on 2 week vacations and their Macs don't check in during that time. Other than that, it works great! However the #1 thing that is required is that our internal server syncs to the atomic clocks the rest of the world uses.
EDIT: I just realized you said you don't have Jamf yet. Until you get Jamf at your company, you can periodically run that command en masse via ARD if you have that.
@ddcdennisb With this script are you placing it in self service. If so, is there somewhere in the policy I also have set things. I edited the script for Chicago, but the policy fails. Any help would be appreciated.
I don't have it running in Self Service. i just have it running on check-in.
Can you share the logs of the script running? Maybe able to see whats happening in there.
@ddcdennisb Here is the error.
Running script Time.sh...
Script exit code: 2
Script result: /Library/Application Support/JAMF/tmp/Time.sh: line 1: {rtf1ansiansicpg1252cocoartf1561cocoasubrtf400: command not found
/Library/Application Support/JAMF/tmp/Time.sh: line 2: syntax error near unexpected token `}'
/Library/Application Support/JAMF/tmp/Time.sh: line 2: `{fonttblf0fnilfcharset0 Menlo-Regular;}'
Error running script: return code was 2.
Also how do you have it set at check in ?? Maybe i can go that route ?
can you also share your version of the script that you are running? Looks like there might be some syntax errors in the code. (going off what i'm seeing in your log posted above).
@ddcdennisb
I only edited timezone = and timeserver=
Should i have made other edits ? Not the best at script. Still learning them.
!/bin/sh
Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone="America/Chicago”
TimeServer="time.apple.com"
####### Pause for network services #######
/bin/sleep 10
#####################################
/usr/sbin/systemsetup -setusingnetworktime off
Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone
Set specific time server
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer
enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
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/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
exit 0
First thing i'm seeing is you want to make sure the "TimeZone="America/Chicago” TimeServer="time.apple.com"" are one 2 different lines
TimeZone="America/Chicago”
TimeServer="time.apple.com"
can you post your script again, this time putting the code in using the >_ button above?

#!/bin/sh
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone="America/Chicago”
TimeServer="time.apple.com"
############# Pause for network services #############
/bin/sleep 10
#################################################
/usr/sbin/systemsetup -setusingnetworktime off
#Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone
#Set specific time server
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer
# enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
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/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
# set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
exit 0
#!/bin/sh
```
```
OK! for some reason your quotations are messed up. As you can see in your last post, after setting the TimeZone variable, everything is green. Can you try deleting that then replacing the quotes and see if that works out better for you?
@ddcdennisb Better ??
#!/bin/sh
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone=“America/Chicago”
TimeServer=“time.apple.com”
############# Pause for network services #############
/bin/sleep 10
#################################################
/usr/sbin/systemsetup -setusingnetworktime off
#Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone
#Set specific time server
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer
# enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
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/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
# set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
exit 0
Here. Try using this code:
#!/bin/sh
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone="America/Chicago"
TimeServer="time.apple.com"
############# Pause for network services #############
/bin/sleep 10
#################################################
/usr/sbin/systemsetup -setusingnetworktime off
#Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone
#Set specific time server
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer
# enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
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/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
# set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
exit 0
Yes! give that a go and see what you get as a result.
@jwilson
{rtf1ansiansicpg1252cocoartf1561cocoasubrtf400
and
{fonttblf0fnilfcharset0 Menlo-Regular;}
This makes me think that maybe your script was typed up in a non-standard text editor. If you use MS Word or even TextEdit to save your text, there is going to be all kinds of extra fluff added for formatting that isn't visible but the script handlers see all of that and don't know how to process it. Make sure you use a text editor like TextWrangler or BBEdit or Atom. These save the text files and nothing but actual text.
Thanks for all the help. So I copied it back in to textedit. Saved it as a .sh file, and it is still giving the same error.
@AVmcclint I am using texteditor, will use text wrangler and update.
Don't use TextEdit. That will always save extra data to the file that will mess up the exectution of the script. TextWrangler or BBEdit or Atom or Sublime... there are many text editors out there that will help you out a lot when you write scripts.
if you are using TextEdit, open a new file and then make sure to make the file Plain Text before saving it. To do this, click on the Format Menu item and then select Make Plain Text.
Thank you @AVmcclint and @ddcdennisb for your help. It is working.
I used this script from @ddcdennisb,
it works like a charm! Unfortunately i get several pop ups on my machine. I get one ever day from Outlook and one from system preferences. Any idea what might cause this? I checked and the ntp servers are set correctly and so is the time zone.
Thanks in advance!