How to silently update OS X and reboot if necesary?
$ sudo softwareupdate --list
$ softwareupdate -a -i &amp;&amp; shutdown -r now


The &amp;&amp; shutdown -r now is purely optional - if you want to only reboot when needed (or never) you can process the output as softwareupdate will print out messages that a reboot is needed when appropriate. This tool - even if updates come from the App Store app, does not update any purchased apps. You need the GUI to update those apps at present time since Apple did not include a tool to automate those updates.

The first just scans for appropriate updates. The second installs all updates followed by a reboot of the Mac. Play around to see what works best for you. It's trivial to automate these using launchd if that suits your needs as well. 

I've had better luck rebooting the Macs before the update. If I'm going to cut users off with unsaved data, I'd rather do that first and let the update go cleanly. Updating a program that is currently running is something I like to avoid.

Here is a nice article explaining the details from Apple. It works fine on non-server version of Mac OS X as noted at the end of the article.