![](/img/trans.png)
[英]How can I run my spark app with python in the background with my computer shut off?
[英]How can I shut down my computer using python script?
我想使用python腳本關閉我的計算機(mac),以獲取我編寫的某些代碼。 我嘗試了以下
os.system('shutdown -s')
os.system('shutdown -h now')
但是這兩個都產生輸出256,而我的系統沒有關閉。
我讀到它可能是由於沒有root特權,但我想我無法通過python提供root特權。 有沒有一種方法可以運行python腳本並關閉上述問題的Mac?
重新啟動:
re_start = ["shutdown", "-f", "-r", "-t", "30"]
對於關機:
shut_down = ["shutdown", "-f", "-s", "-t", "30"]
因此:
def shutdown(self):
import subprocess
subprocess.call(shut_down)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.