You can run `caffeinate` for a pre-determined amount of time to **prevent sleeping for a specified block of time**, say for 4 hours while you download something, and then run it in the background by adding & to it:
```bash
caffeinate -t 14400 &
```
To stop, run ‘kill’ and the process id:
```bash
kill 77181 // or whatever the ID is
```
You can also run:
```bash
killall caffeinate
```
see: [Disable Sleep on a Mac from the Command Line with caffeinate](http://osxdaily.com/2012/08/03/disable-sleep-mac-caffeinate-command/)