A few months back, we blogged about 7 applications for your Mac to prevent it from sleeping. While these programs make the process extremely simple, OSX Mountain Lion comes inbuilt with a ready command line tool that makes this process extremely easy.
Fire up Terminal and run the following command:
caffeinate -i -t 36000 &
The command above will tell OS X to not sleep on idle (-i) and to keep running for 36,000 seconds or 10 hours (-t 36000). The ampersand at the end tell caffeinate to run in the background. This means you can close the terminal window and caffeinate will continue to run.
At the end of the time period, the program will exit and your normal power settings come into play.
If you’re interested in a bit more details about caffeinate, check out the documentation.