Proxmox-ve6.2.1登錄帳號前無操作自動關閉屏幕、熄屏、屏保


 

起因

最近在用proxmox做虛擬機,都是開機后就丟在一邊不管。但它的屏幕一直亮着,不會自動熄屏。網上查了些資料,都是用“setterm --blank 1”命令,是可以實現,重啟后又要進去輸一次太麻煩。想在登錄帳號前執行,用以下方法解決:

 

新建rc-local.service文件

添加以下內容。把下面命令全部復制到提示符中運行。它的vi快捷鍵與centos7中的有點不同,改用cat很方便

cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target
EOF

 


新建rc.local文件

proxmox找不到rc.local文件,自己新建一個。

cat > /etc/rc.local <<EOF
#!/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.
 
# bash /root/bindip.sh

setterm --blank 2
exit 0
EOF

上圖倒數第3行的命令中作用是兩分鍾后關屏幕


 

設置開機啟動

把這兩文件設置為開機啟動,當然要先添加權限,最后檢查它的狀態

chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service
systemctl status rc-local.service

可以看到圖片中Active:active (exited)……,說明成功了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM