Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Linux 掛起/喚醒命令 rtcwake 詳解:定時休眠與自動喚醒實戰

編輯:Linux 系統常見問題解答

rtcwake 利用硬件 RTC(實時時鐘)鬧鐘,讓系統進入掛起狀態並在指定時間自動喚醒,適用於定時備份、節能測試、自動化任務等場景。

基本語法

rtcwake -m 模式 -s 秒數
rtcwake -m 模式 -t 時間戳

常用掛起模式

模式說明
mem掛起到內存(S3,待機),功耗極低,喚醒快
disk休眠到磁盤(S4,休眠),斷電可恢復
standby待機(S1),CPU 停止,內存供電
freeze軟件掛起,不切換電源狀態
off關機(需 RTC 支持喚醒)
on不掛起,僅設置 RTC 鬧鐘
no不掛起,僅設置歐洲標準鬧鐘

實戰示例

# 60 秒後自動喚醒(掛起到內存)
rtcwake -m mem -s 60

# 指定喚醒時間(Unix 時間戳)
rtcwake -m mem -t $(date -d '07:00' +%s)

# 僅設置鬧鐘不掛起(配合腳本檢查)
rtcwake -m on -s 3600

查看幫助

man rtcwake
rtcwake --help

注意事項

  • 需硬件/BIOS 支持 RTC 鬧鐘喚醒,虛擬機中可能不生效。
  • 掛起前建議同步時間(hwclock -w),避免時間偏差導致喚醒異常。
  • 生產環境慎用,確保關鍵服務能容忍掛起/恢復過程。

善用 rtcwake,可實現「夜間低峰自動掛起、早晨業務高峰前自動喚醒」的節能自動化運維。

Copyright © Windows教程網 All Rights Reserved