Updated: Send softwareupdate command through ARD
This script will run software updates only on machines that are logged out. This ensures you don’t reboot machines that are in use and don’t leave machines in an inconsistent state (by not rebooting after patching). This is not a perfect solution to patching but it’s better than nothing. You can even schedule this to run on a recurring basis.
Update: Added sleep command with random wait. This will help alleviate some load on your SUS and perhaps prevent a DOS attack. Thanks to rsaeks via Twitter.
Copy and paste the following into an Apple Remote Desktop (ARD) “Send Unix Command” window and send as root:
#!/bin/sh <pre lang="bash"># Random number of seconds to wait # The more machines you use this with, the higher the number should be sleep `expr $RANDOM % 120`
if who | grep console; then
echo Machine is in use
exit 1
fi
COMMAND_LINE_INSTALL=1 softwareupdate -i -a
shutdown -r now
exit 0
Related posts:
- Bind to OD Script & Add to Computer Group
- Script to Configure the Mac OS X firewall
- Add user to admin group with Applescript
- Migrate Local User to Domain Account
- Add directory services data to LANDesk inventory
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.



I found this on a mailing list or sysadmin blog a while back. I used to wait until off peak hours to run updates.
With this command I can run anytime. Thanks for posting this!
Yea, this is great – thanks!!