We all know how to use the System Preferences to enable and disable system sleep in OS X, but what about remotely via SSH or locally in the Terminal?
Also, what about preventing users from being able to put a system to sleep via the Apple menu in OS X?
Use Terminal to prevent system from going to sleep when idle:
sudo systemsetup -setcomputersleep Never
Use Terminal to set a predetermined idle time to put the system to sleep:
sudo systemsetup -setcomputersleep 60
Use Terminal to get the current sleep settings:
sudo systemsetup -getcomputersleep
Use Terminal to disable the sleep function via the Apple Menu:
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.PowerManagement SystemPowerSettings -dict SleepDisabled -bool YES
Use Terminal to re-enable the sleep function via the Apple Menu:
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.PowerManagement SystemPowerSettings -dict SleepDisabled -bool NO
These functions can be vert handy for Xsan connected Macs where you have unsupported storage subsystems that maybe affected by Macs entering sleep mode.