
我想在計算機運行 30 分鐘後將其關閉。
我在 Raspbian(Raspberry Pi)上,我嘗試輸入/etc/rc.local
:
shutdown -h 30
exit 0
但它不起作用。更重要的是,我啟用了自動登錄,但它現在停止工作(它顯示 X 登錄提示),這表明rc.local
可能沒有正確完成(?)。
請問,有人可以幫我進一步嗎?
答案1
輸入這一行
@reboot /path/to/file
在 sudo 的crontab
( sudo crontab -e
) 中。file
是一個可執行文件,內容為
#!/bin/bash
at -f /path/to/anotherfile now + 30 minutes
最終,anotherfile
也是一個可執行文件,其內容
#!/bin/bash
/sbin/shutdown -h now
這當然是殘酷的,您可能希望引入一些變體,以對用戶的遲緩行為更加寬容,例如您可以使用
/sbin/shutdown -h +1 I am not feeling well today, I quit (in 1 minute).