如何解决树莓派 SSH 待机一段时间后自动断开 bug All In One
如何解决树莓派 SSH 待机一段时间后自动断开 bug All In One
# 等待⌛️一分钟后,不取消就立刻关机 ✅
$ sudo shutdown -H
$ ssh pi@raspberrypi.local
raspberry pi 3 close wlan power management ✅
# 查看
$ iwconfig
# Command to read the current power saving mode (Stretch)
$ sudo iw wlan0 get `power_save`
# Command to `power_save off`
$ sudo iw wlan0 set power_save off
# To make this permanent add the following line to `/etc/rc.local`
$ cat /etc/rc.local
# sudo 必须 ✅
$ sudo vim /etc/rc.local
# add below line before exit 0 ✅
/sbin/iw dev wlan0 set power_save off
https://www.weigu.lu/sb-computer/raspi_tips_tricks/index.html#link_4
Raspberry Pi 关闭 WLAN 电池管理
/ 电源管理
防止 SSH 一段时间后自动断开连接
# view power management status
$ iwconfig
# edit config
$ sudo vim /etc/rc.local
# or
$ sudo nano /etc/rc.local
# add below line code before `exit 0`
iwconfig wlan0 power off
$ sudo reboot
# or
$ sudo shutdown -r now
# check power management status, again
$ iwconfig
demo
Power Management:on
$ iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11 ESSID:"ziroom1001"
Mode:Managed Frequency:2.417 GHz Access Point: 80:12:DF:91:00:AA
Bit Rate=72.2 Mb/s Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=64/70 Signal level=-46 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:29 Invalid misc:0 Missed beacon:0
solution ✅
$ iwconfig
$ cat /etc/rc.local
$ sudo reboot
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# 禁用电源关闭 ✅
iwconfig wlan0 power off
exit 0
https://www.youtube.com/watch?v=BqIVmKtzITo
ip.sh
#!/usr/bin/env bash
# coding: utf8
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
printf "🌲🍓我的IP地址是 %s\n" "$_IP"
fi
exit 0
<<EOF
./ip.sh
My IP address is 192.168.18.135 fd80:eae6:1258:0:d1c5:2a7f:abad:cbb5
🌲🍓我的IP地址是 192.168.18.135 fd80:eae6:1258:0:d1c5:2a7f:abad:cbb5
EOF
关闭电源节能管理 ???
DPMS (Display Power Management Signaling)
DPMS(显示器电源管理
信号)
# 修改 lightdm.conf
$ sudo vim /etc/lightdm/lightdm.conf
# 新增 一行
xserver-command=x -s 0 -dpms
# s 0 关闭屏幕保护
# -dpms 是关闭电源节能管理
https://blog.js-css.com/topics/2022/03/20/111/
https://blog.csdn.net/zhangyx22/article/details/109038699
https://pimylifeup.com/raspberry-pi-disable-screen-blanking/
同一个 WIFI 局域网无法互相 ping 通 ❌
SSH server 默认关闭了 ❓
# 显示器,开机后,在树莓派配置中将SSH开启即可。
$ sudo service ssh start
$ sudo service ssh status
# 配置自动开启 SSH ✅
$ sudo vim /etc/rc.local
# add below line
sudo service ssh start
raspberry pi ssh Host is down
https://raspberrypi.stackexchange.com/questions/41595/why-cant-i-ssh-to-raspbian-anymore
https://stackoverflow.com/questions/41318597/ssh-connection-refused-on-raspberry-pi
https://www.raspberrypi.com/documentation/computers/remote-access.html
solutions
- 关闭
无线网卡
电源管理
bug ❌
$ ls /sys/class/net/
# eth0 lo wlan0
$ ls /sys/class/net/wlan0/device/driver/module/drivers
# usb:rtl8192cu
# 8192cu
$ cat /sys/module/8192cu/parameters/rtw_power_mgnt
# 1
# 1 说明你的无线网卡的电源处于管理之下,为了`省电`会在不必要的时候关闭无线网卡
# 关闭电源管理
$ sudo touch /etc/modprobe.d/8192cu.conf
# vim / vscode
# Disable power management, 设置成 0
options 8192cu rtw_power_mgnt=0
# 立即重启 树莓派
$ sudo shutdown -r now
# 检查一下是否无线电源管理已经关闭
$ cat /sys/module/8192cu/parameters/rtw_power_mgnt
# 0
# 0 已经关闭电源管理了
???
# 没有 8192cu ❌
$ ls -al /sys/module/
$ ls -al /sys/module/ | grep 8
drwxr-xr-x 5 root root 0 May 27 00:47 8021q
drwxr-xr-x 3 root root 0 May 27 00:47 8250
drwxr-xr-x 3 root root 0 May 27 00:47 bcm2708_fb
drwxr-xr-x 7 root root 0 May 27 00:47 bcm2835_codec
drwxr-xr-x 7 root root 0 May 27 00:47 bcm2835_isp
drwxr-xr-x 6 root root 0 May 27 00:47 bcm2835_mmal_vchiq
drwxr-xr-x 3 root root 0 May 27 00:47 bcm2835_mmc
drwxr-xr-x 7 root root 0 May 27 00:47 bcm2835_v4l2
drwxr-xr-x 6 root root 0 May 27 00:47 cfg80211
drwxr-xr-x 7 root root 0 May 27 00:47 i2c_bcm2835
drwxr-xr-x 4 root root 0 May 27 00:47 lan78xx
drwxr-xr-x 3 root root 0 May 27 00:47 r8152
drwxr-xr-x 7 root root 0 May 27 00:47 snd_bcm2835
$ ls -al /sys/module/8250/parameters/
$ ls -al /sys/module/8021q
树莓派3 关闭电源管理
✅ ???
# 查看 电源管理 状态
$ iwconfig
$ cat /etc/network/interfaces
$ vim /etc/network/interfaces
# 目标wlan里加一句
wireless-power off
# 重启
$ sudo reboot
# 或
$ sudo shutdown -r now
https://myblog.galaxymaxmetal.xyz/archives/64
https://www.cnblogs.com/cloudrivers/p/11496408.html
❌
https://gist.github.com/hofmannsven/9132419?permalink_comment_id=3159275#disable-power-management
https://www.raspberrypi-spy.co.uk/2015/06/how-to-disable-wifi-power-saving-on-the-raspberry-pi/
树莓派 3 & 截屏软件
# superuser do === sudo
$sudo apt-get ???
https://shumeipai.nxez.com/2019/07/30/how-to-take-a-screenshot-on-the-raspberry-pi.html
refs
https://mitnk.github.io/2016/01/fix-raspberry-pi-2-wifi-ssh-disconnect-issue/
https://askubuntu.com/questions/96333/what-wireless-driver-am-i-using
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16481735.html
未经授权禁止转载,违者必究!