Ubuntu Server WiFi (USB Adapter) does not recover after router restart, cron jobs stop logging
13:51 07 Apr 2026

System Details

  • OS: Ubuntu Server

  • Kernel: 5.15.0-173-generic

  • Architecture: x86_64

  • Setup: Headless server (accessed via SSH / Tailscale)

  • Network: WiFi using a USB WiFi adapter (Realtek RTL871X driver)


Problem Summary

I have a home Ubuntu server connected to WiFi using a USB adapter.
When my home router restarts, the server:

  • Disconnects from WiFi

  • Attempts recovery via scripts (cron jobs)

  • Sometimes recovers successfully

  • But after some time, all cron jobs stop producing logs

  • SSH connection drops (connection reset)

  • I need to manually reboot the server to recover


Network Configuration (nmcli)

connection.autoconnect:                 yes
connection.autoconnect-priority:        10
connection.autoconnect-retries:         -1 (default)
connection.autoconnect-slaves:          -1 (default)

Cron Jobs

Running as root:

*/2 * * * * /bin/bash /home/madhur/scripts/wifi-recover.sh
*/2 * * * * sleep 20 && /bin/bash /home/madhur/scripts/ping-monitor.sh
*/2 * * * * sleep 40 && /bin/bash /home/madhur/scripts/tailscale-watchdog.sh

Scripts Overview

I have 3 scripts:

  1. wifi-recover.sh

    • Checks interface state, IP, and ping

    • If down → runs:

      systemctl restart NetworkManager
      
      
    • Then brings interface up and checks connectivity

    • Restarts tailscaled after recovery

  2. ping-monitor.sh

    • Pings 8.8.8.8

    • If failed → toggles WiFi using:

      nmcli radio wifi off/on
      
      
  3. tailscale-watchdog.sh

    • Checks Tailscale health via JSON

    • Restarts tailscaled if offline


Observed Logs

WiFi Recover

[12:52:04] Wi-Fi DOWN → Restarting NetworkManager...
[12:52:45] ❌ Recovery FAILED (No IP assigned)

[12:54:01] Wi-Fi DOWN → Restarting NetworkManager...
[12:54:41] ✅ Recovery SUCCESS (IP assigned)

Ping Monitor

[12:52:04] PING FAIL → 100% packet loss
[12:54:01] PING FAIL → Network unreachable
[01:16:03] PING OK

Tailscale

[12:54:01] Online=false → restarting tailscaled
[12:54:09] ✅ restarted

Critical Issue

After the router restart (~12:54 AM):

  • Recovery appears successful

  • But:

    • SSH disconnects (connection reset)

    • Cron logs stop appearing after that point

    • Scripts no longer seem to execute

  • System becomes unreachable until manual reboot


Additional Observations

From journalctl:

  • NetworkManager is restarted multiple times

  • WiFi driver logs:

    • RTL871X: nolinked power save

    • firmware reloads

  • Tailscale shows DNS failures:

    • Temporary failure in name resolution

Questions

  1. Why do cron jobs stop producing logs after network recovery?

    • Is cron actually stopping, or are scripts failing silently?
  2. Is restarting NetworkManager from cron a bad practice?

    • Could this be causing system instability or race conditions?
  3. Could the USB WiFi adapter (Realtek RTL871X) be causing instability?

    • Known issues with power saving / driver resets?
  4. What is the correct way to ensure automatic WiFi reconnection on Ubuntu Server?

  5. Should I:

    • Avoid systemctl restart NetworkManager?

    • Use only nmcli commands?

    • Use a systemd service instead of cron?

  6. How can I make the system:

    • Recover reliably after router restart

    • Keep cron/scripts running

    • Avoid needing manual reboot


Goal

I want a fully autonomous recovery system such that:

  • If WiFi/router restarts → server reconnects automatically

  • Tailscale reconnects

  • SSH remains stable (or recovers)

  • No manual intervention required


ubuntu wifimanager networkmanager nmcli