简体   繁体   English

如何使用python将PC置于睡眠模式?

[英]How to put a PC into sleep mode using python?

While the copy is in progress, can we put a PC into sleep mode for a specific period of time, then wake up and continue copy using python script? 在进行复制的过程中,我们是否可以将PC置于特定时间的睡眠模式,然后唤醒并使用python脚本继续复制? Can you please share the code? 能否请您共享代码?

Actually this is possible using shell script. 实际上,使用shell脚本可以做到这一点。

Most machines manufactured after 2000 support real-time clock wakeup. 2000年之后制造的大多数机器都支持实时时钟唤醒。 There are many reasons to do so, one of which would be to record a TV program at a certain time. 这样做有很多原因,其中之一就是在某个时间录制电视节目。 See ACPI Wakeup . 请参阅ACPI唤醒

You'll have to explain what you mean by "While the copy is in progress" - there's not much to go on in the question. 您将必须解释“复制正在进行中”的意思-这个问题没有什么要继续的。 While OS drivers have suspend/resume functions, I don't know how to tell the python interpreter to save its state in the middle of running a script and then resume after wakeup. 虽然OS驱动程序具有暂停/恢复功能,但我不知道如何告诉python解释器在运行脚本的过程中保存其状态,然后在唤醒后恢复。 It's possible that the OS suspend/hibernate would fully capture the state of a copy operation and resume without a hiccup, but I wouldn't trust it to do so without substantial testing. 操作系统挂起/休眠可能会完全捕获复制操作的状态并在没有打ic的情况下继续运行,但是我不相信它会在没有进行大量测试的情况下这样做。

If you have "Wake On Lan" enabled you could potentially run a python script on a different PC and trigger the wake up after your specific period of time. 如果启用了“局域网唤醒”,则有可能在另一台PC上运行python脚本,并在特定时间段后触发唤醒。

The scripts would probably need to talk to each other, unless you just do it all at times set in advance. 这些脚本可能需要互相交谈,除非您只是在预先设置的时间进行所有操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM