Simple Shell Script To Wake Up NAS Devices Using Linux or Unix Computer

in Categories Script last updated March 30, 2013

A simple bash shell script to wake up nas devices / home servers using mac address.

# A simple shell to Wake Up nas devices / home servers 
# Tested on RHEL, Debian and Ubuntu base desktop systems.
# ----------------------------------------------------------------------------
# Written by Vivek Gite <>
# (c) 2012 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated: 14/May/2012
# ----------------------------------------------------------------------------
# add your nas devices mac address here #
# path to wakeonlan #
# who am I ? #
# send magic packet #
   local n="$1"
   [[ "$n" == "" ]] &&  { echo "$_me ($FUNCNAME#$LINENO) error: Mac address not set."; exit 1; } || $__wakeupserver $n
## main logic ##
case $_me in
   wakeup.nas03) __wakeup $_nas03;;
   wakeup.nas02) __wakeup $_nas02;;
   wakeup.nas01) __wakeup $_nas01;;
	*) echo "$_me I can not understnad the request."

How do I use this script?

First, install Wake-on-LAN (WOL) client under Unix or Linux operating systems.

Next, download this script and put in your home directory as
wget -O ''
mv ~/bin/
chmod +x ~/bin/

Edit the script and set nas server mac address. Finally, create a symbolic link using ln command:
ln -s wakeup.nas01
ln -s wakeup.nas02
ln -s wakeup.nas03

To wake up nas01 using WOL, enter:

Share this on:

2 comment

  1. The Buffalo nas will start in this way above! Thats good.

    But then after 3 min it will go down again because of Buffalo NAS systems have an “Auto Power” mode: the NAS stays up&running while the (windows) pc is running. It’s done with a (windows) service, always running, that send 3 (why 3?) wake-on-lan packets to the NAS every (about) 30 seconds. When you shutdown the pc, the NAS stops receiving w-o-l packets, wait about 3 minutes, then shutdown itself.

    I found a solution for that here:

  2. _nas02=”00:xx:yy:zz:aa:bb”

    It would be nicer to do an indirect call to the variable that is the name with which you call the program to avoid the case clause, but I don’t know how that is done in bash. I mean to recall the value of the variable whose name is the value of a variable.

    Have a question? Post it on our forum!