Turn on your server when Kodi / XBMC starts

Last updated: 24/04/2016 - 4 years, 8 months ago

An article tagged as: linux, ubuntu

Twitter Facebook Reddit


I have a client computer running XBMC on Ubuntu. I also have a separate computer acting as a server. When i switch on the client computer, i want the server to switch on too.

This method can be used for any linux client to switch on any server. XBMC 13+ and Kodi have a setting to wake a server, but it doesn't seem to work properly yet. This method always does the job.

Enable Wake on Lan (WoL) on server

Our How to enable Wake on Lan article has full instructions on how to make sure your server is set-up to be woken up by a Wake-on-Lan packet.

Find out the server MAC address

Access the server via ssh or open a terminal

$ ifconfig | grep HWaddr

Write down the displayed MAC address which appears on the same line as eth0, you will need it next

Create Wake on Lan (WoL) script

Access the client machine via ssh or open a terminal

$ cd /etc/init.d
$ sudo nano mywol

Copy the following script content

#! /bin/sh
# location /etc/init.d
# MAC address of backend


# Issue wakeonlan at intervals until our own network interface
#  is active and the magic packet is successfully sent.
until /usr/bin/wakeonlan $SERVER_MAC > /dev/null 2>&1 ; do
    sleep 1

exit 0

Paste clipboard contents into nano using:- shift + insert

Replace the value of SERVER_MAC with the MAC address of the server you want to wake-up

Save file using ctrl + o

Exit nano using ctrl + x

Make sure the scipt is excecutable

$ sudo chmod 755 mywol

The above could have been done using an upstart job, but i have never found this to work.

Running the script on system boot

A program called wakeonlan is required on your client computer to issue wake-up messages

Install wakeonlan using the following command

$ sudo apt-get install wakeonlan

Now we can test our script

Switch off your server then on the client, do the following

$ sudo /etc/init.d/mywol

After a few moments the server will switch on.

If it fails to switch on, please make sure you have:

  • Used the correct MAC address in the script
  • Have applied this article to your server

Once we are happy the script works we need to make it run on boot

$ sudo update-rc.d mywol defaults

To test this, switch off your server, then reboot your client. The server should start-up a few moments after the client.