With any fleet of MacOS devices, the time will come to restart some devices. Maybe it is for maintenance, for a software update, or for troubleshooting an issue. The most straightforward method for restarting a device with Addigy is to simply send it the reboot command. 


However, sending a simple restart command will cause the Addigy agent to go offline before an exit code can be sent to the Addigy cloud portal. This will result in an error: 5001 exit code.      



To avoid this, we can modify our simple restarts just a little bit. The following command runs the same reboot but sends it to the background using the & at the end. We also add a short five-second wait using the sleep command to make sure the Addigy agent has time to exit the script and send a value up to the Addigy cloud servers. 


(sleep 5 && reboot) &> /dev/null &


Here are the results from the Addigy portal:



This methodology can also be applied to normal shutdowns as well.


(sleep 5 && shutdown -h now) &> /dev/null &