Naf*_*Kay 1 command-line macos
我需要每天晚上 10:00 关闭 Mac。Mac 是否有我应该使用的调度程序,还是应该遵循cron?我是 Linux 用户,这是一个朋友问我的问题。我希望能够像在 Linux 中一样从终端插入命令:
crontab -e
Run Code Online (Sandbox Code Playgroud)
或者
(crontab -l >/dev/null 2>/dev/null && (crontab -l && echo "@reboot do-stuff") | crontab -)
Run Code Online (Sandbox Code Playgroud)
从命令行执行某些操作的最佳选择是什么?我对 OSX 不太熟悉。
cron是为了兼容性,但它已被 取代launchd,它确实具有安排事件的能力。在您的属性列表文件中,您需要StartCalendarInterval一个值为简单 a Hour/Minute对的键:
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>22</integer>
<key>Minute</key>
<integer>00</integer>
</dict>
Run Code Online (Sandbox Code Playgroud)