Skip to content

Instantly share code, notes, and snippets.

@friartuck6000
Last active August 29, 2015 13:56
Show Gist options
  • Save friartuck6000/6315a18baee4cd642fd5 to your computer and use it in GitHub Desktop.
Save friartuck6000/6315a18baee4cd642fd5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Red Bull for Hard Drives
# ------------------------------------------------------------------------
# Run this script once to keep your mounted Time Machine or other external
# hard drive(s) from falling asleep and making your system hang every time
# the drive wakes up.
#
# Usage:
# 1. Be sure to chmod +x this file before trying to execute it.
# 2. Run /path/to/redbull.sh '{VOLUME_NAME}', replacing {VOLUME_NAME} with
# the case-sensitive name of the volume you want to keep from sleeping
# (keep the single quotes though).
# 3. Enter your admin password when prompted.
# 4. Rejoice.
if [ "$1" != "" ]; then
VOLNAME="$1"
VOLPATH="/Volumes/$VOLNAME"
if [ -d "$VOLPATH" ]; then
sudo touch "$VOLPATH/.nosleepforyou"
echo "*/5 * * * * touch -c '$VOLPATH/.nosleepforyou'" | sudo crontab
echo
echo "All done. You can verify by using the command 'sudo crontab -l'"
echo "(that's a lowercase L)."
echo
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment