Scheduled unmount disk(s) (macOS)

How to unmount (eject) disk(s) from macOS on schedule without using Automator or any other external app or scripter.

*The content was originally found on reddit, written by /u/neuralspark –shamelessly pasted here to serve as personal archive :-)

Make a new text file named com.diskejector.YOUR_VOLUME_HERE.plist on your desktop. Open it, and paste this into it. The Hour value is a 24 hour format, so this would eject all volumes on the disk that has the drive named YOUR_VOLUME_HERE on it at 6 PM everyday. Obviously change the YOUR_VOLUME_HERE and the 18 to meet your requirements.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
Save and close it

Open Terminal, and type the following lines:

sudo mv ~/Desktop/com.diskejector.YOUR_VOLUME_HERE.plist /Library/LaunchDaemons/

sudo chown root:wheel /Library/LaunchDaemons/com.diskejector.YOUR_VOLUME_HERE.plist

sudo chmod 644 /Library/LaunchDaemons/com.diskejector.YOUR_VOLUME_HERE.plist

sudo launchctl load -w /Library/LaunchDaemons/com.diskejector.YOUR_VOLUME_HERE.plist

Boom! Now your disk will unmount each night at 6 PM. It will fail silently if the disk isn’t there, so no harm no foul.

Repeat this for each volume you need to unmount, replacing YOUR_VOLUME_HERE with the drive name.