How to Set Up Wake-on-LAN and Scheduled Power on a Linux Server (Save Electricity)

A server that runs Pi-hole and the VPN needs to be on all the time. A server that holds the media library and runs backups doesn't — it could sleep from midnight to seven and wake when someone presses play. Wake-on-LAN lets any device on the network switch it on with a "magic packet", and rtcwake lets the server switch itself off and back on at set times. On a 40 W machine, sleeping eight hours a night saves roughly a third of its electricity.
Quick reference
| Task | Command / setting | |
|---|---|---|
| BIOS | enable Wake on LAN / Power On by PCI-E / ErP off | |
| Check the NIC supports it | `sudo ethtool enp3s0 | grep Wake-on → Supports Wake-on: ... g` |
| Enable in Linux | sudo ethtool -s enp3s0 wol g (made permanent below) | |
| Wake it from another Linux box | wakeonlan b8:27:eb:12:34:56 | |
| Wake from a phone | any "Wake On LAN" app, enter the MAC | |
| Shut down and wake at 07:00 | sudo rtcwake -m off -l -t $(date -d 'tomorrow 07:00' +%s) |
1. Enable it in the BIOS
Reboot into the BIOS (Del or F2). Look under Power or Advanced for Wake on LAN, Power On By PCI-E/PCI, or Resume by LAN and enable it. Disable ErP / EuP (deep power-off states that cut power to the network card). Save.
2. Enable it in Linux
Find the interface and its MAC:
ip link
sudo ethtool enp3s0 | grep Wake-on
Supports Wake-on: pumbg with a g means magic-packet wake is supported. Wake-on: d means it's currently off. Turn it on:
sudo ethtool -s enp3s0 wol g
Make that permanent — Netplan can do it:
sudo nano /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
enp3s0:
dhcp4: true
wakeonlan: true
sudo netplan apply. (Or a systemd service running the ethtool line at boot.)
Write down the MAC address: b8:27:eb:12:34:56.
3. Test it
Shut the server down: sudo poweroff. From another machine on the same network:
- Linux/Mac: sudo apt install wakeonlan then wakeonlan b8:27:eb:12:34:56
- Windows: WakeMeOnLan from NirSoft, or Depicus Wake on LAN
- Phone: any Wake On LAN app — enter the MAC and the broadcast address 192.168.1.255
- Home Assistant: the wake_on_lan integration gives you a switch for it
The server should start within a few seconds. If it doesn't, the BIOS setting is the usual culprit.
4. Wake from outside the house
Magic packets are broadcasts and don't cross the internet. Options: keep a Pi (3 W) always on running Pi-hole, VPN and a wake script you trigger over SSH; or use a router that supports WoL from its admin page; or Home Assistant on the Pi with the switch exposed in its app.
5. Scheduled sleep and wake
The server can power off and set its own alarm clock:
sudo rtcwake -m off -l -t $(date -d 'tomorrow 07:00' +%s)
-m off is a full shutdown; -m mem is suspend-to-RAM (wakes in seconds, uses ~1 W, but not every board resumes reliably — test it). -l says the hardware clock is local time (use -u if timedatectl shows the RTC in UTC, which is Ubuntu's default).
Put it in root's crontab for midnight:
0 0 * * * /usr/sbin/rtcwake -m off -u -t $(date -d 'tomorrow 07:00' +%s) >> /var/log/rtcwake.log 2>&1
Add a guard so it doesn't shut down mid-backup or while someone's watching a film:
#!/bin/bash
# /usr/local/bin/night-shutdown.sh
pgrep -x restic >/dev/null && exit 0
curl -s http://127.0.0.1:8096/Sessions -H "X-Emby-Token: $JELLYFIN_KEY" | grep -q NowPlayingItem && exit 0
/usr/sbin/rtcwake -m off -u -t $(date -d 'tomorrow 07:00' +%s)
6. Measure it
A plug-in power meter (or a smart plug with energy monitoring) on the server for a week tells you what it actually draws. Idle at 15 W and asleep 8 hours a night saves about 44 kWh a year; a 60 W old desktop saves four times that.
Troubleshooting
Doesn't wake after a poweroff but does after suspend. The BIOS cuts standby power to the NIC: disable ErP/EuP, or try -m mem instead.
Wakes, then goes straight back to sleep / reboots. Another timer or a cron job fired. Check the crontab and journalctl -b -1.
rtcwake wakes at the wrong time. The -l / -u flag doesn't match the RTC setting. timedatectl | grep RTC.
Wake-on-LAN setting resets after reboot. The Netplan wakeonlan: true line is missing, or the driver resets it. A systemd oneshot service with ExecStart=/usr/sbin/ethtool -s enp3s0 wol g after network.target fixes stubborn cards.
Wrapping up
BIOS on, ethtool wol g made permanent, a MAC address in a phone app, and rtcwake with a guard script at midnight. The server that only needs to be awake when you are now costs a third less to run, and nobody in the house notices except the meter.
