Shutdown script doesn't work as a cronjob
Your script doesn't fetch the BOOT_TIME of the remote hosts properly in the cron environment.

I recommend to remove the cronjob and create a launch agent usr.remoteshutdown.plist instead in /Users/admin/Library/LaunchAgents/ with the following content:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Disabled&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;usr.remoteshutdown&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/bin/bash&lt;/string&gt;
        &lt;string&gt;/Users/admin/Shutdown/sh/remoteshutdown.sh&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Hour&lt;/key&gt;
        &lt;integer&gt;23&lt;/integer&gt;
        &lt;key&gt;Minute&lt;/key&gt;
        &lt;integer&gt;0&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Then load the launch agent by entering in the Terminal.app:

launchctl load /Users/admin/Library/LaunchAgents/usr.remoteshutdown.plist


Please adjust the (admin) user name and the name and location of the shutdown script in the plist.



To test this you don't have to wait 24 hours. Simply either


remove the sudo in the shell script temporarily
comment out the line ssh "${ADMINUSER}@${MAC}" 'sudo /sbin/shutdown -h now'
comment out the ssh ... shutdown -h now line and insert a line echo "Boot: ${BOOT_TIME}"
echo the ssh ... shutdown -h now line (instead of executing it)


Then modify StartCalenderInterval in the launch agent to a point of time in the near future (current time +3 minutes). Unload and load the plist with:

launchctl unload /Users/admin/Library/LaunchAgents/usr.remoteshutdown.plist
launchctl load /Users/admin/Library/LaunchAgents/usr.remoteshutdown.plist




The shell script requires SSH key-based authentication and that the admin has a special line in the sudoers files of the remote hosts to allow sudo shutdown ... without entering passwords!