在bash脚本中防止系统睡眠/关机/重启 [英] Prevent system sleep/shutdown/reboot in a bash script

查看:157
本文介绍了在bash脚本中防止系统睡眠/关机/重启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过执行需要很长时间才能运行的bash脚本,我可以防止手动执行的系统睡眠/关机/重启.如果登录的用户会收到一条消息,那很好,但这不是必需的.通常,我正在寻找OS X的可行解决方案,但对于Linux来说也不错.

By execution of a bash script which takes a long time to run I will prevent a manual executed system sleep/shutdown/reboot. It would be nice if the logged on user will get a message but it´s not necessary. Normally I´m looking for a working solution for OS X but for Linux would also be nice.

推荐答案

在OS X上,您可以使用

On OS X, you can use the caffeinate -s /path/to/your/script command to prevent sleep while your script runs.

这篇关于在bash脚本中防止系统睡眠/关机/重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆