By default, Macs are designed to be user machines. While they are very easy to set up as servers, a few of the standard settings are not ideal for hosting services.
If you are planning on using a Mac as a server - that is, you expect it to be running services indefinitely - there are some settings you should check on first, before you are remote and having issues.
Launch System Preferences and navigate to the Energy Saver pane. Change these settings:
- Computer Sleep: Never
- Display Sleep: Never
- disable “Put hard disks to sleep when possible”
- enable “Start up automatically after a power failure”
This is a screenshot from my Mac mini which @macminicolo was kind enough to set up like this for me.
Reading Values from the Command Line
The values behind the Energy Saver preferences pane appear to be stored in User Defaults and can be read with the following command:
The “Automatic Restart On Power Loss” key is the most important.
Because of the way these settings are stored, they are difficult to set using the
defaults command, which requires passing a plist file in order to set a tree of key-value pairs such as the above “Custom Profile” entry. The danger with doing this is that many values are set or unset in one step and these values will likely change through the years as OS X evolves.
Changing Values from the Command Line
A better approach for manipulating these values from the command line is to use the
pmset command. This utility can be used to read the current Energy Saver values (read them all with
pmset -g, but uses shorter key aliases than defaults. The pmset keys are mostly space-free for easier typing on the command line.
These are the values you will always want to change when setting up a Mac server: