因为家里有台限制的电脑, 就装上CentOS系统当做服务器使用; 可是CentOS默认的关闭盖子后系统就睡眠了, 在网上查了下, 关闭盖子后正常工作
启动CentOS, 修改/etc/systemd/logind.conf 文件
vim /etc/systemd/logind.conf
文件打开是这样的:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=no
#InhibitorsMax=8192
#SessionsMax=8192
将其中的 #HandleLidSwitch=suspend 改成 HandleLidSwitch=lock
ignore(什么都不做)
poweroff(关机)
reboot(重新启动)
halt(进程都挂起)
suspend(待机挂起)
hibernate(休眠)
lock (锁屏,任可正常工作)
因为默认是suspend 所以当关闭盖子后, 所有进程都挂起了, 远程连接也无法使用了.
最后修改完毕后, 重启或者 systemctl restart systemd-logind生效.