Scheduled suspend and automatic wake-up for Linux servers.
AutoWake is a lightweight POSIX shell utility that uses a systemd timer to suspend a physical Ubuntu/Debian server and a hardware real-time clock (RTC) alarm to resume it.
I created AutoWake because I was too lazy to manually start and suspend my server every week. It automates the routine: the server goes to sleep when I no longer need it and wakes up before I need it again.
AutoWake is complete and ready for installation. The timer is intentionally left disabled during installation so hardware wake support can be validated on the target server before activation.
| Action | Time |
|---|---|
| Suspend | Every Friday at 19:00 |
| Wake | Every Monday at 06:00 |
| Timezone | Server's configured local timezone |
| RTC device | /dev/rtc0 |
AutoWake calculates calendar dates in local time, so the elapsed weekend can be 58, 59, or 60 hours when the timezone offset changes.
The editable architecture diagram shows the installation, diagnostic, scheduled suspend, and hardware wake flows. Open it with draw.io or the diagrams.net desktop app.
- A physical Ubuntu/Debian server running systemd.
- GNU
date,sed,grep, util-linux (rtcwake), and systemd. - Firmware and hardware support for suspend-to-RAM and RTC wake alarms.
- Root access for installation, alarm setup, and suspension.
Suspend-to-RAM requires continued power. AutoWake resumes a suspended machine; it cannot turn on a machine that has lost or disconnected power.
For a fresh installation, run:
git clone https://github.com/apache261/Autowake.git
cd Autowake
sudo ./install.shIf the repository is already downloaded, open its directory and run only:
sudo ./install.shThe installer does not activate the schedule. Verify the installation with:
sudo /usr/local/sbin/autowake check
/usr/local/sbin/autowake previewAfter completing a hardware wake test, enable the weekly timer:
sudo systemctl enable --now autowake.timer
systemctl list-timers autowake.timerThe installer places:
autowakein/usr/local/sbinautowake-uninstallin/usr/local/sbin- configuration in
/etc/autowake.conf - units in
/etc/systemd/system/autowake.serviceand/etc/systemd/system/autowake.timer
An existing configuration is preserved. The installer regenerates the timer from that configuration and reloads systemd. It never enables or starts the timer automatically.
sudo /usr/local/sbin/autowake check
/usr/local/sbin/autowake preview
sudo /usr/local/sbin/autowake runcheckvalidates configuration, looks for dependencies, the RTC device, and the kernel'smemsuspend interface. It does not set an alarm or suspend.previewprints the next suspend and its associated wake time. It has no power-management side effects.runis intended for the timer. It only acts during the five minutes after a scheduled suspend, arms the alarm first, and then callssystemctl suspend.
Do not invoke run on a production server merely as a diagnostic: when called
inside its execution window it will suspend the machine.
After a successful resume, AutoWake runs every executable regular file in
/etc/autowake/wake.d in filename order. This can be used for service health
checks, notifications, storage checks, or other site-specific recovery work.
Wake hooks run as root. Install them as root-owned files and do not make them writable by untrusted users:
sudo install -o root -g root -m 0755 my-wake-check.sh \
/etc/autowake/wake.d/20-my-wake-checkNon-executable files are ignored. If a hook fails, AutoWake records the failure in the journal, continues running the remaining hooks, and marks the service run as failed after all hooks finish. Hooks run only after suspends initiated by AutoWake; they do not run after a reboot or an unrelated manual suspend.
An example hook checks for llama-server and starts it with nohup when it is
not running:
sudo install -o root -g root -m 0755 \
examples/wake.d/10-ensure-llama-server \
/etc/autowake/wake.d/10-ensure-llama-serverThe example uses absolute paths below /home/nisadmin/llama.cpp and runs the
process as nisadmin. Edit LLAMA_SERVER, MODEL, and RUN_AS_USER if your
installation differs. A dedicated systemd service is still recommended if the
program must also recover after a reboot or power interruption, because wake
hooks run only after an AutoWake suspend.
/etc/autowake.conf uses unquoted KEY=value entries:
SUSPEND_WEEKDAY=Fri
SUSPEND_TIME=19:00
WAKE_WEEKDAY=Mon
WAKE_TIME=06:00
RTC_DEVICE=/dev/rtc0Weekdays are Mon through Sun; times must use 24-hour HH:MM format. The RTC
device must be an absolute path below /dev.
After editing the configuration, preview it and rerun the installer to
regenerate the timer's OnCalendar setting:
/usr/local/sbin/autowake preview
sudo ./install.sh
systemctl cat autowake.timerFirst run non-invasive checks on the target server:
sudo /usr/local/sbin/autowake check
/usr/local/sbin/autowake preview
timedatectlDuring a maintenance window, test the hardware with a short direct suspend and wake cycle (the following example requests a wake after two minutes):
sudo rtcwake -m mem -d /dev/rtc0 -s 120Confirm that the machine resumes and its services recover. A short test does not establish that the RTC supports the full weekend alarm range. Test the full configured interval on the target hardware before relying on AutoWake.
After hardware validation, enable scheduling explicitly:
sudo systemctl enable --now autowake.timer
systemctl list-timers autowake.timerIf the server wakes early for any reason, AutoWake leaves it awake until the next scheduled suspension.
systemctl status autowake.timer
systemctl list-timers autowake.timer
journalctl -u autowake.service
sudo systemctl disable --now autowake.timerAn invalid configuration or failed rtcwake command prevents suspension. Runs
delivered more than five minutes late are logged and skipped. The timer uses
Persistent=false, so a missed event is not replayed after downtime.
Run the installed uninstaller to disable the timer and remove AutoWake:
sudo /usr/local/sbin/autowake-uninstallTo preserve /etc/autowake.conf for a later reinstall:
sudo /usr/local/sbin/autowake-uninstall --keep-configCustom wake hooks are preserved during removal. The uninstaller removes the hook directory only when it is empty.
The uninstaller can also operate on an isolated staged installation without contacting the host's systemd instance:
./uninstall.sh --root /tmp/autowake-stageRun the complete automated suite with:
make testTo test installation without writing to system directories or contacting the host's systemd instance:
./install.sh --root /tmp/autowake-stage
./uninstall.sh --root /tmp/autowake-stageIt checks POSIX shell syntax, validates generated systemd units when
systemd-analyze is available, exercises calendar and daylight-saving
boundaries using fixed timestamps, and uses mocked power commands to verify
ordering and failures. It does not perform hardware validation.
RTC capabilities vary; consult the rtcwake manual when validating the target server.
For common operational questions, see the FAQ.