Sending message from Terminal does not work when the Mac is sleeping
The Mac must be powered on to run your script. Only a few Apple specific processes are allowed to run via PowerNap.

pmset

You can use pmset to schedule your Mac to wake in the middle of the night.


  pmset allows you to schedule system sleep, shutdown, wakeup and/or power on. "schedule" is for setting up one-time power events, and "repeat" is for setting up daily/weekly power on and power off events. Note that you may only have one pair of repeating events scheduled - a "power on" event and a "power off" event. For sleep cycling applications, pmset can schedule a "relative" wakeup or poweron to occur in seconds from the end of system sleep/shutdown, but this event cannot be cancelled and is inherently imprecise.
  
  
  type - one of sleep, wake, poweron, shutdown, wakeorpoweron 
  date/time - "MM/dd/yy HH:mm:ss" (in 24 hour format; must be in quotes) 
  time - HH:mm:ss 
  weekdays - a subset of MTWRFSU ("M" and "MTWRF" are valid strings) 
  owner - a string describing the person or program who is scheduling this one-time power event (optional)
  


See How to Power On Your Mac at a Specific Date and Time for more details, including a graphical approach, and alternative tools.