Shutdown Macs script

angela04
New Contributor

I am new to using Jamf but in my department we need to use jamf to shutdown the macs we use. Any idea or script that can work for that? Thanks

1 REPLY 1

russeller
Contributor III

Hey there @angela04 Welcome!
There is a command in macOS that shuts down Macs right away called the shutdown command. The full syntax would be /sbin/shutdown -h now the -h would indicate halt, that powers the Mac off immediately. If you replace the -h with -r it'll reboot the Mac. If you wanted this to happen on your Macs at a specific time, you could create a policy in JAMF under the Files and Processes section where you can input that command. Then you can tell the policy times it is allowed to execute. In this case you'd go to the General tab, then Client-Side Limitations and indicate when the policy wouldn't run (which would normally be during work hours). The problem with using this command in a policy it tends not to let the policy complete successfully because the Mac would shutdown before its done completing the policy. It's not a very graceful solution. A better solution might be write a script that create a launch daemon that would schedule the shutdown and let the policy complete successfully. If you are interested in that we can definitely dive deeper into the topic. You can also search Jamf Nation for examples of launch daemons because there are tons of examples.