Category filter
Script to set time zone for Mac
A macOS device automatically configures the time zone under the Date & Time preferences depending on its current location. However, if you want to specify the time zone of a device over the air, you can get it done with the help of scripts. The
Execute Custom Script action from Hexnode streamlines this process where you run customized scripts directly from the UEM console.
Scripting language – Bash
File extension – .sh
Set time zone
1 2 3 4 5 |
#!/bin/sh #!/usr/bin/env bash sudo systemsetup -settimezone $1 |
Replace $1 with your preferred time zone and deploy the above custom script from the Hexnode UEM console to the device.
Consider the following script. It explicitly sets the device’s time zone to “Pacific/Ponape”:
1 2 3 4 5 |
#!/bin/sh #!/usr/bin/env bash sudo systemsetup -settimezone Pacific/Ponape |
There is a possibility that your device still shows the incorrect date and time even after setting the time zone. This might be because you have not enabled the Set date and time automatically option on the device. Either enable this option manually on the device or deploy the script given below from the Hexnode console to the device to automatically adjust the time and date.
1 |
/usr/sbin/systemsetup -setusingnetworktime on -setnetworktimeserver time.apple.com |
List time zones
You can obtain a list of time zones from the device by running the following script from the UEM console:
1 |
sudo systemsetup -listtimezones #lists various time zones |
Any of the listed time zones replace the $1 argument of the Set time zone custom script, which can then be deployed from the Hexnode console to the device.