OSX: Check for Mac sleep

Source: Internet
Author: User

Mac does not sleep. It seems simple, but it is not too watery, especially it is a little weird and annoying. It is one of the most strange Mac problems. In the Windows window world, this does not seem to be a problem. When it comes to Mac, it almost becomes a problem.

Although Apple has an official document describing the solution to this problem, it is still relatively detailed: If your Mac does not enter sleep or remain asleep. However, the strange thing about this problem is that the appearance looks the same, which leads to a wide variety of software and hardware factors. If you look at the official documentation, you will think: Tile, it is too complicated. If a person can write down all the detailed steps in the document, is it a level on the Internet?

In order to find the root cause of the problem, the internal factors of the system are our concerns. In order to help you answer questions-what we hope to do in this article, this article attempts to analyze the possible causes of such problems in as much detail as possible from multiple aspects, use the system method provided by OSX to monitor and identify the specific causes of the problem, and try to provide a solution as much as possible. In fact, on the other hand, it also involves various possibilities of making the apple machine out of sleep, such as using out-of-the-box software, commands supported by the system, and even self-programming. In short, based on our study of the original official documents of apple, we can further learn about and set up the operating system, so that we can control the apple machine freely.

Because most of the content in this article involves hardware and internal operating mechanisms of the system as well as analysis and operation of system information, it is not suitable for ordinary users. It is best to do so with the help of experienced technical personnel, understand the relevant instructions and then change the system settings.

General factors:

Let's keep a list of them. common software may be the most common cause. For example, let's take a look at the following for troubleshooting:

Whether to play music in iTunes. It will disable the Mac computer from sleep to keep the music playing Dropbox from uploading/downloading files. You can disable LAN sync to solve this problem. uninstall Drobo Dashboard. log out of Google Drive. other software, such as the smcFanControl program. There are also software that specifically prohibits sleep, such as InsomniaX, Caffeine, NoSleep, wimoweh, and other system resources sharing, such as Internet/file sharing.

There are 6th items. If you want to use off-the-shelf software to prevent machine sleep, you can consider these software.

Body start:

In fact, there are two root causes of sleep: one is that a program disables the system from sleep, which is achieved through the assertions mechanism supported by the system, the following is a detailed description. In another case, although the Mac receives a wake-up message after sleep, the user may have no intention or forgotten or is not aware of the impact of these settings, this causes the system to wake up and respond to special signals. Therefore, the following describes how to perform the check.

Before further analysis, check whether the system is set to sleep (disabled or not). You can check it in the energy-saving system configuration, or use the energy management command pmset provided by OSX. The understanding and use of pmset can help us to have a detailed understanding of the Power Supply Configuration of Apple Computers and improve the degree of freedom. We will also rely on this command to start our work later.

Basically, run the following command to view the current energy configuration:

pmset -g
Or
pmset -g custom
The former only displays the current power supply configuration, and the latter can display different battery and external power supply configurations.
Use the preceding command to check the sleep configuration value. If it is 0, sleep is disabled. If it is non-zero, sleep is triggered after the system is idle for several minutes.

Asserted interface:

Assertion is an interface of the system's underlying I/O energy management mechanism for applications defined in IOPMLib. The official document reads: "access to common power management facilities, like initiating system sleep, getting current idle timer values, registering for sleep/wake comprehensions, and preventing system sleep."

In order to check in detail whether the program has set assertions to prevent System sleep, you can view the current system assertions:

/usr/bin/pmset -g assertions

Now we use an example to analyze the assertions in a typical scenario:

Assertion status system-wide:   PreventUserIdleDisplaySleep    1   CPUBoundAssertion              0   PreventSystemSleep             1   PreventUserIdleSystemSleep     1   InternalPreventDisplaySleep    1   ExternalMedia                  0   UserIsActive                   1   ApplePushServiceTask           0   BackgroundTask                 1Listed by owning process:  pid 2922(screensharingd): [0x00000005000002b1] 00:04:37 NoDisplaySleepAssertion named: "Nameless (via IOPMAssertionCreate)"   pid 44(mds): [0x0000000c00000133] 00:20:38 BackgroundTask named: "com.apple.metadata.mds"   pid 2924(ScreensharingAg): [0x00000005000002bf] 00:00:15 NoDisplaySleepAssertion named: "screen sharing wake display"   pid 2924(ScreensharingAg): [0x0000000a000002ba] 00:00:05 UserIsActive named: "screen sharing wake display"   pid 2520: [0x0000012c000009d8] PreventUserIdleSystemSleep named: "com.apple.audio.'AppleHDAEngineOutput:1B,0,1,2:0'.noidlesleep" 
  pid 2423(caffeinate): [0x0000000800000292] 00:09:13 PreventSystemSleep named: "caffeinate command-line tool" Details: caffeinate asserting foreverLocalized=THE CAFFEINATE TOOL IS PREVENTING SLEEP.  pid 25(powerd): [0x0000000100000185] 00:15:58 PreventUserIdleSystemSleep named: "com.apple.powermanagement.ttyassertion" Details: /dev/ttys000Localized=A remote user is connected. That prevents system sleep.  pid 25(powerd): [0x0000000d000002ae] 00:04:41 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 19 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002af] 00:04:38 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 22 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002b0] 00:04:38 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 22 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002b6] 00:03:52 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 67 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002b7] 00:03:52 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 67 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002bc] 00:01:32 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 208 secs Action=TimeoutActionRelease  pid 25(powerd): [0x0000000d000002be] 00:00:18 InternalPreventDisplaySleep named: "com.apple.powermanagement.delayDisplayOff" Timeout will fire in 282 secs Action=TimeoutActionReleaseKernel Assertions: None

It consists of two parts:

In the first part, "Assertion status system-wide" displays the status according to the asserted category. If each status is activated by an asserted inserted by a user, 1 is displayed, and 0 is not activated. each type of assertions will affect the system. Common examples include PreventUserIdleSystemSleep and PreventUserIdleDisplaySleep. The second part shows you which process it is and generates assertions of that type. To terminate an assertion, the process of the assertion is terminated as soon as the influence of the assertion on the system is released:
sudo kill <pid> 
System settings:
Some system behaviors set by default may be changed:

For example, disabling the laptop screen cover will cause the system to sleep. If this behavior is affected by changes, use this command to restore the default behavior:

sudo pmset -a lidwake 1
Changing the power supply features will also wake up, and this behavior will be changed with the following command:
sudo pmset acwake 0
If an active ttys process, such as a terminal program or even a remote connection, has an impact, use this command to disable:
sudo pmset -a ttyskeepawake 0

System log:

You can check system messages and run the following command to determine the actions that have been awakened:

/usr/bin/syslog | grep -i "Wake reason"

Possible messages are:

EC. PowerButton PWRB (User): the User pressed the power key EHC2: keyboard button or mouse move EHC1: USB connected iDevices? : Received Wake-on-Lan packet EHC/OHC/USB: USB or FireWire Device
Listen 0: Enable RTC on the laptop screen: Real-time clock messages. For example, to disable the acceptance of Wake-on-Lan packets, run the following command:
sudo pmset -a womp 0
The Bluetooth device may also stop sleeping. Check all Bluetooth devices and disable the device from waking up the computer.

Sleep delay:
Another case is that the running of a program delays the sleep action. You can start with this:
pmset -g log | grep slowresponse
If it finds a program, it needs to run a command similar to the following, open it with a text editor software, find slowresponse to see which program is delayed. For example, the following result:
Domain: applicationresponse.timedout- Message: Kernel cupsd com.apple.powermanagement.applicationresponse.timedout 30000 ms- Time: 30/03/10 19:06:55 HAEC - Signature: cupsd- UUID: EDA8296C-E84D-4B86-8AE9-5321B8676227- Result: Noop- Response time (ms): 30000

The printer program keeps trying to print the cause of sleep delay.

Programming:

Finally, for more information about programming to change sleep features, see the description of Assersions in Apple's official IOPMLib, for example, here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.