Why?

  • Saving electricity
  • Saving HDD/SSD resource
  • No need to monitor that nothing is broken yet
  • Silence if the machine is equipped with a fan and/or HDD

## How do I turn it off?

We execute the command and it will turn off at midnight:

echo "10 0 * * * root /sbin/poweroff" > /etc/cron.d/poweroff

To disable it, delete the file `/etc/cron.d/poweroff'.

In TrueNAS SCALE, it’s a little different: go to System Settings -> Advanced -> Cron Jobs -> Add (run as root, the rest of the settings are obvious).

How do I turn it on?

The most convenient way is to send a “magic” packet to the network interface (by MAC address, since the IP address is still unavailable at this time). To do this, both machines must be on the same network segment.

Client Setup

How to install the utility on mac OS (on other systems in about the same way):

brew install wakeonlan

How to run (7c:83:00:11:22:33 – The MAC address of the machine to turn on):

wakeonlan 7c:83:00:11:22:33

For convenience, I made an alias:

alias on_nas="wakeonlan 7c:83:00:11:22:33"

Setting up the machine to be turned off

Check if the BIOS has the appropriate setting. If there is, then turn it on.

Check under root if the command will work without errors:

/sbin/ethtool -s eth0 wol g
netlink error: cannot enable unsupported WoL mode (offset 36)
netlink error: Invalid argument

– this is just an example of an error (Raspberry Pi 4 does not support such activation - for it only through a smart outlet)

If the operating system is configured through the Network Manager (Ubuntu and Rocky), then you can use the following commands:

# get a list of connections to find out the exact name
nmcli connection

# configure WoL activation:
nmcli connection modify "Wired connection 2" 802-3-ethernet.wake-on-lan magic

For TrueNAS SCALE:

  1. The name of the network device can be viewed in the Network -> Interfaces section.
  2. Go to System Settings -> Advanced -> Init/Shutdown Scripts -> Add. Adding the PostInit command:
/sbin/ethtool -s enp2s0 wol g

A new article has been published about shutdown (there are several more ways to turn it off): Remote shutdown of the home server.