Ubuntu 16.04关机延迟异常求助:疑似与WiFi使用相关
Hey there! Let's tackle this quirky shutdown delay issue you're facing with your Ubuntu 16.04 laptop. The detail that it only pops up after you've used WiFi (but not every single time) gives us a solid clue to work from. Here's how to diagnose and fix it:
Ubuntu logs every step of the shutdown process, and we can use that to pinpoint which service is dragging its feet.
- Open a terminal and run this command to pull up the logs from your last shutdown:
Thejournalctl -b -1 | grep -i "stop\|kill\|timeout\|shutdown"-b -1flag targets the previous boot/shutdown session. Keep an eye out for entries mentioning timeout or a service failing to stop properly—odds are it's a WiFi-related service likenetwork-manageror your wireless card's driver. - If the log is too long, narrow it down to the final minutes before shutdown:
journalctl -b -1 --since "1 hour ago" | tail -n 100
Given your observation, the problem is almost certainly tied to WiFi services. Try these targeted fixes:
Method 1: Speed up NetworkManager's shutdown timeout
Sometimes NetworkManager gets stuck waiting for wireless connections to close cleanly. We can force it to give up faster:
- Open NetworkManager's config file:
sudo nano /etc/NetworkManager/NetworkManager.conf - Add this line under the
[main]section:
This tells NetworkManager to exit after 5 seconds instead of waiting indefinitely.shutdown-timeout=5 - Save and exit (press
Ctrl+O, hit Enter, thenCtrl+X), then restart the service to apply changes:sudo systemctl restart NetworkManager
Method 2: Check your wireless card driver
Closed-source drivers (like those for Broadcom cards) often cause shutdown hangs. Let's verify your card and tweak drivers:
- First, find your wireless card model:
lspci | grep -i wireless - If it's a Broadcom card, try switching from the closed-source to open-source driver:
- Uninstall the closed-source driver:
sudo apt remove bcmwl-kernel-source - Install the open-source alternative:
sudo apt install firmware-b43-installer - Reboot and test shutdown behavior.
- Uninstall the closed-source driver:
Method 3: Manual workaround for immediate fixes
If you hit a slow shutdown unexpectedly, you can manually kill WiFi-related processes before shutting down:
- Turn off WiFi first:
nmcli radio wifi off - Stop the NetworkManager service:
sudo systemctl stop NetworkManager - Now shut down normally:
This not only fixes the immediate issue but also confirms if NetworkManager is the root cause.sudo shutdown -h now
After applying any of these changes, test by using WiFi then shutting down several times. If the delay disappears, you've nailed it. If not, check logs for issues with wpa_supplicant (the core WiFi connection service) using:
journalctl -u wpa_supplicant -b -1
A quick side note: Ubuntu 16.04 is no longer officially supported. While this isn't directly causing your shutdown issue, upgrading to a newer LTS version (like 20.04 or 22.04) would give you better hardware support and system stability, which might resolve this old bug for good.
内容的提问来源于stack exchange,提问作者Bib-lost

