Additionally, SailfishOS (Mer) has quite a nice dbus interface with which you can set any command to be run and have the phone wake up from the switched off state to do it.