Mac terminal stop hard drive from spinning Can I stop hard disk drives from spinning using Terminal?

The reason why I want to know is because I have my Mac to backup at midnight however I do not want my HDD to be spinning all the time. I would also like a way to spin it back up again.

This is an external drive.
In a Terminal or script, you can use the pmset command to sleep/wake the computer and more.

From: man pmset

sleepnow - causes an immediate system sleep

sudo pmset sleepnow

Schedules the system to automatically wake from sleep on July 4, 2016, at 8PM.

sudo pmset schedule wake "07/04/16 20:00:00"

Note: I've added sudo to the above pmset commands as this is necessary unless running as root which under OS X is not the norm.

From: Quick Tip: Save Battery by Spinning Down Hard Drive Sooner

sudo pmset -a disksleep 5

sudo - allows a standard “admin” user to run programs usually reserved for the “root” user. These are usually processes that affect the system as a whole – like this one.

pmset - this is the name of the utility we’re using.

-a - this “flag” tells the pmset utility that we’re applying it to all power configurations: battery, charger, and uninterrupted power supply. If you want to affect JUST when you’re on battery power, change this flag to “-b”

disksleep - this is the parameter we want to change: disk sleep time. This parameter is for 10.5 and later; in previous OS versions, you should use “spindown” instead.

5 - this is the number of minutes the system waits before sleeping the disk. OS X’s defaults are 10 minutes. We halved it here, so it spins down faster, but not so fast that it’s always spinning up (which would be counter to our needs). You may need to adjust this number to a point that works best for you.