在VirtualBox的CentOS虛擬機中設置自動關機,可以通過以下幾種方法實現:
shutdown 命令shutdown 命令是CentOS中最常用也是最推薦使用的關機工具,因為它能夠安全地關閉系統。
在特定時間關機:使用以下命令格式:
shutdown -h +分鐘數
例如,如果你想在10分鐘后關機,可以使用:
shutdown -h +10
設置在每天的特定時間關機:使用以下命令格式:
shutdown -h 22:22
這將在每天的22:22自動關機。
crontab 設置定時關機你可以使用 crontab 來設置定時關機。首先,編輯 /etc/crontab 文件,在文件末尾加入如下行:
00 20 * * * root shutdown -h now
00 22 * * * root shutdown -h now
00 23 * * * root shutdown -h now
這將在每天的20:00、22:00和23:00自動關機。
以上就是在CentOS VirtualBox虛擬機中設置定時關機的方法,你可以根據自己的需求選擇合適的方式。