This project addresses the automation requirement for the .155 Windows computer to stay powered on during holidays/weekends and to be fully shut down after the holiday ends. Because the computer cannot sleep (the GPU light stays on), and a cold start of WeChat requires scanning a QR code with a phone, the decision logic is placed on the .223 server: the script windows155_period.py checks at 18:00 every day whether "tomorrow is a holiday and today is a workday"; if so, it sends a WOL magic packet to power on the computer. At 08:00 every day, it checks whether "yesterday was a holiday and today is a workday"; if so, it shuts down the computer remotely via SSH, and automatically skips if the computer is already powered on or already shut down. Holiday data comes from GitHub's holiday-cn, includes weekends and make-up workdays, and supports caching and daily updates; before 2027 data is released, it falls back to weekend determination. On the Windows side, automatic login, WeChat auto-start, and a Moments sync scheduled task are configured, so the computer stays online after booting, and shutdown is triggered uniformly by the server. The solution has completed dry-run and actual testing: weekend and National Day date determinations are correct, the computer boots about 25 seconds after WOL, and SSH becomes available in about 26 seconds.
Features
- 按“节假日前一晚 18:00”自动 WOL 开机,假期期间保持开机
- 按“节后首个工作日 08:00”SSH 远程关机,避免休眠
- 基于 holiday-cn 自动判断周末/调休,缓存并每日更新
- 已开机/已关机状态自动跳过,支持 --force 手动补发
- Windows 端自动登录、微信自启与朋友圈同步计划任务
- systemd timer 定时执行,旧周五唤醒定时器已禁用
Stack: Python · systemd timer · WOL · SSH · Windows 计划任务 · PowerShell · holiday-cn
- Prepare the environment: keep
/opt/projects-site/scripts/windows155_period.pyon the .223 server, and confirm that the WOL and SSH remote shutdown chain for the .155 Windows machine works. - Configure timers: create and enable
win155-period-wake.timer(daily at 18:00) andwin155-period-shutdown.timer(daily at 08:00); after making changes, run systemd daemon-reload. The oldblog-wake155.timerhas been disabled. - Configure Windows: enable automatic login and set WeChat to start automatically; create a logon-triggered scheduled task
MomentsNightlySync, whose flow is to start WeChat, wait for QR code scanning (up to 6 hours), runnightly_sync.ps1to sync Moments and keep the machine powered on; createMomentsDailySyncfor incremental sync every day at 02:00. - Manual verification: on .223, run
python3 /opt/projects-site/scripts/windows155_period.py --mode wake --forceto test startup, and run--mode shutdown --forceto test shutdown. Measured results show that after WOL the machine boots in about 25 seconds, and SSH becomes available in about 26 seconds. - Daily use: no intervention is required; holiday data is pulled automatically, and after the 2027 schedule is published, the script will update automatically. To change the rules, modify the script or timer, then run daemon-reload.