Is there a way to prevent my Mac from sleeping during a file copy?

I'm copying a lot of files (over 700 GB) and it takes hours to complete. Is there a way to keep the Mac from sleeping before the copy process completes? I don't want to sit by the computer and moving my mouse from time to time.

I tried to set my Energy Saver settings as:

Energy Saver settings showing sleep disabled

But sometimes it still dies. So currently, I have to sit by the laptop and wait.


Solution 1:

caffeinate rsync

Consider using the command line tool rsync to safely copy large amounts of data on your Mac. Prefix the command with caffeinate to keep your Mac awake during the copy.

The Terminal.app command will look something like:

 sudo caffeinate rsync -vaE --progress /Volumes/SourceName /Volumes/DestinationName

rsync has the benefit of being able to resume failed or interrupted copies.

If the copy has already begun, run caffeinate with the flag -t <seconds> for a specific duration or -w <pid> for the life time of a specific process.

Solution 2:

You can use the freely available app "Amphetamine" from the Mac App Store to keep the Mac awake:

https://apps.apple.com/us/app/amphetamine/id937984704?mt=12

Another similarly free app is "Jiggler":

http://www.sticksoftware.com/software/Jiggler.html

Solution 3:

If you always remain on AC power during the copy and your above Energy Saver settings are indeed accurate, then I can think of no reason why your system would enter idle sleep unless there is some process that specifically forces a sleep at some point. You can check for sleep entry & causes by examining the power management log:

$ pmset -g log

In any case, in order to prevent the system from going to sleep you can acquire a power management assertion with the use of caffeinate(8), which is built in to macOS and accessible via Terminal:

$ caffeinate

The system will not sleep until you exit (via Control + C).

From your description, I suspect that you might not actually be on AC power the whole time and instead are running off the battery. Please double check this first.

Solution 4:

Plenty of options already here, but just to complete the set…

System Prefs > Desktop & Screen Saver > Screen Saver > Hot Corners…

Choose a corner to Disable Screen Saver & just push your cursor hard into that corner when you want it to stay awake.

I've never actually tried this on a laptop, but I've been using it successfully on Mac Pros for over a decade.