本文介绍了是否可以在OSX中检测Power Nap/DarkWake模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过启动启动的守护进程.即使在DarkWake期间,它也将运行,并且没有时间在OS X重新进入睡眠之前完成.

I have a daemon process started via launchd. This will be running even during DarkWake and has no time to finish before OS X goes back to sleep again.

我可以想到以下解决方案,但没有找到实现此目的的方法.

I can think of the following solutions, but didn't find a way to achieve this.

  1. 不要使该守护进程在DarkWake期间运行.

  1. Don't make this daemon process run during DarkWake.

我浏览了Apple文档和论坛,但没有找到任何参考.

I went through Apple documentation and forums but didn't find any reference for this.

在通过守护进程进行DarkWake的过程中,操作系统要等到完成为止.

During DarkWake via daemon process make the OS wait until its done.

尝试在守护进程中调用pmset noidle和caffeinate.没用OS X进入睡眠状态.在DarkWake模式下,OS X似乎抑制了许多通知的传递.

Tried with calling pmset noidle and caffeinate in daemon process. It didn't work. OS X went to sleep. It seems OS X suppresses the delivery of many notifications when in DarkWake mode.

在守护进程中检测DarkWake模式.

Detect DarkWake mode in daemon process.

没有找到任何解决方案/方法来检测DarkWake模式.

Didnt find any solution/method to detect DarkWake mode.

请帮助.

推荐答案

也只需找出有关这些唤醒的信息.使用log实用程序,我可以在系统自行唤醒(即使未激活powernap)时看到这些行:

Just needed to find out about these wakes too.Using the log utility, I can see these lines when the system wakes up on its own (even without powernap activated):

2019-04-11 22:18:00.622600 + 0200 0x250默认0x0 83 0 powerd:[powerd:sleepWake] vm.darkwake_mode:1-> 1

2019-04-11 22:18:00.622600+0200 0x250 Default 0x0 83 0 powerd: [powerd:sleepWake] vm.darkwake_mode: 1 -> 1

2019-04-11 22:18:00.625413 + 0200 0x250默认0x0 83 0 powerd:[powerd:sleepWake]由于RTC/维护原因,从深度空闲[CDN]唤醒了DarkWake:

2019-04-11 22:18:00.625413+0200 0x250 Default 0x0 83 0 powerd: [powerd:sleepWake] DarkWake from Deep Idle [CDN] due to RTC/Maintenance:

为了检测到这一点,应该执行以下操作:

In order to detect this, something like this should work:

log show --last 1m --predicate 'subsystem == "powerd"' | grep "DarkWake from Deep Idle"

或者,在脚本中使用咖啡因也可能有效(尚未对此进行测试).

Alternatively, using caffeinate in your script might work too (haven't tested this yet).

这篇关于是否可以在OSX中检测Power Nap/DarkWake模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 04:11