

Osascript -e ‘tell the application “System events” to sleep’ You can also target the “System Events” application if you come across something that is preventing sleep: Using either method should overwrite everything else running in Mac OS X and put the system to sleep.

Osascript is a command line tool that executes OSA scripts, the -e flag executes the script in quotes instead of searching for a file, and the text in quotes is standard AppleScript. Osascript -e ‘tell application “Finder” to sleep’ The syntax for the AppleScript sleep method is as follows: Using AppleScript from the command line is another way to initiate hibernation directly from Terminal. How to Put Mac to sleep from the command line with AppleScript
