
作者:CPP手艺人 来源: CPP手艺人 日期:2026-12-01 19:26:50
如何让VPS不待机
VPS(Virtual Private Server,何让虚拟专(zhuan)用服务器)是一种虚拟化的计算(suan)资源,可以为用户提供独立(li)的待机操作系统和硬件环境,在实际使用过程中,何让我们可能会遇到需要(yao)让VPS不(bu)待机的待机情(qing)况,例如在远程桌面连(lian)接时,何让或者在进行某些需要保持系统运行的待机操作,那么(me)如何实现让VPS不待机呢?何让本文将详细介绍几种方法。


1、待机临时禁用休眠功能

在Windows系统中(zhong),何让可以通过以下步骤禁用休眠功能:
a. 打(da)开“控制面板”。待机
b. 点击“硬件和声音”。何让
c. 点击“电源选项”。待机
d. 在左侧菜单中选择“更改计算机睡眠时间”。何让
e. 将“关闭显示器”和“进入睡眠状态”设置为(wei)“从不”。待机
f. 点击“保存更改”。何让
2、修改注册表
在Linux系统中,可以通过修改注册表来禁止休眠功能,创建一个名为disable_hibernate.reg的注册表文(wen)件,内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPowerPowerSettings7bc4a363-da86-4464-bafb-ff5bb81db4be238C9FA8-0AAD-41ED-83F4-97BE242C8F20]
"Attributes"=dword:00000001
以管理员身份运行命令提示符,执行以下(xia)命令导入注册表文件(jian):
reg import disable_hibernate.reg
1、关闭休眠功能(Windows)
在Windows系统中,可以使用powercfg命令来关闭休眠功能,打开命令提示符,输入以下命令:
powercfg /h off
2、关闭休眠功能(Linux)
在Linux系统中,可以使用systemctl命令来关闭休眠功能,创建一个名(ming)为disable_hibernate.service的服务文件,内容如下:
[Unit]
Description=Disable Hibernate mode for system shutdown and reboot events (for Debian systems only)
After=syslog.target network.target remote-fs.target nss-lookup.target timesync.target watchdog.target apt-daily.timer unattended-upgrades.timer udev-trigger startlimitd.service automount-nfs.service iscsid.service inetutils-resolvconf.service avahi-daemon.service avahi-autoipd.service avahi-dnsconfd.service cups-cleanup-timer lightdm.service dbus-daemon dbus-userspace.service gpm.service sshd.service systemd-networkd-wait-online.service systemd-timesyncd.service apparmor.service auditd.service nagios3-checkpoints.service rsyslog.service libvirtd.service systemd-tmpfiles-setup.service systemd-journald.service systemd-logind.service systemd-udevd.service systemd-random-seed.service systemd-timesyncd@systemd-timesyncd.service systemd-timesyncd@systemd-timesyncd-pathfinder.service systemd-timesyncd@systemd-timesyncd-pathfinder-wait.service systemd-timesyncd@systemd-timesyncd-pathfinder-wait.service systemd-timesyncd@systemd-timesyncd-pathfinder-wait2.service systemd-timesyncd@systemd-timesyncd-pathfinder2.service systemd-timesyncd@systemd-timesyncd2.service systemd-timesyncd@systemd-timesyncd2.service systemd-timesyncd@systemd-timesyncd2@sockets.service systemd-timesyncd@sockets2.service systemd-timesyncd@sockets3.service systemd-timesyncd@sockets3@sockets3.service systemd-vfsmount@procfs.service systemd-tmpfiles@devtmpfs.service systemd-tmpfiles@runtmpfs.service systemctl enable –now hibernateonboot.timer disable_hibernate@%I service name="Hibernate on Boot" enabled="yes" description="Disable Hibernate mode for system shutdown and reboot events (for Debian systems only)" type="oneshot" startdelay="1min" action="/usr/lib/systemd/system/disable_hibernate@%I.sh" after="networking">
创建一个(ge)名为disable_hibernate@%I.sh的脚本文件,内容如下:
!/bin/sh -e BEGIN INIT INFO Provides: disable_hibernate@%IRequired-Start: $remote_fs $syslog $network $named $time $tmpfs $mailslot $cron $anaconda $pulse $syslogrotate $tcpdump $acpid $gpm $rsyslog $avahi $auditd $firewalld $input$input$netfilter$iptables$ip6$ip6tables$arpwatch$bluetooth$bspwm$conntrack$cups$cpufreq$cpuspeed$devicemapper$debootstrap$dhcpcd$directio$diskstats$dunst$dropbear$execstart$fail2ban$firewallmark$filesystems=${ locale}.UTF8 $firewalls $gdm3 $gnome_session $htop $iwd $keepawake $lesslockscreen $lxpolkitlock $netcat $networkmanager $ntpd $open='open'box $parted $pciutils $pulseaudio $rcctl $(psmisc | grep tty) $(psmisc | grep serial) $(psmisc | grep xterm) rrdtool screen saver stopxserver ureadahead udev usermod useradd userdel vim visudo wpa_supplicant wpa_action wpa_cli wpa_passphrase wpa_supplicant wpa_state wakealarm xinit xloadavg xsetroot xterm zsh top man chkconfig sysctl depmod modprobe modinfo free ramfree swapfree inodefree blockcount blocksize iostat iotop iftop netstat netstat tcpdump nmap uptime whowhois whoami id ps pstree procstat vmstat yum update yum list installed yum history last reboot epel release repolist yum clean all yum makecache fast install yum remove epel* yum groupinstall "Development Tools" yum install epel* yum install kernel headers kernel source rpmdevtools yum install python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python34 yum install epel* kernel headers kernel source rpmdevtools yum install python