The caffeinate command is pretty cool. It keeps your computer from going to sleep. It can run in a couple of different ways. There’s a timer that prevents sleep for a little while. You can also run another command from within caffeinate that keeps the system awake until the other command is finished. Here, we’ll scp a file called source file to a host called servername and keep the system from going to sleep until the process is finished:
caffeinate -s scp sourcefile me:servername/targetfile
Here, we’ll just use the boring command to tell the computer not to go to sleep for an hour:
caffeinate -t 3600 &