You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Mountain goes to sleep when streaming video

After upgraded to Mountain Lion my iMac (mid 2011) goes to sleep mode when streaming movies via NFS sharing (to Popcorn Hour).


How can i prevent this from happening?

iMac, OS X Mountain Lion

Posted on Jul 28, 2012 2:21 PM

Reply
12 replies

Jul 28, 2012 3:05 PM in response to Toltje

@Toltje, I don't think it's a work-around at all. Mountain Lion imposed it's own default energy saver settings on me as well during installation. To prevent your Mac from going to sleep, you should follow @ClayG's advice, or at a minimum, extend the time before the Mac goes to sleep while using the power adapter.


Caffeine, available in the Mac App Store HERE, is free, works well and provides a TEMPORARY solution to modifying your poser saving settings.

Aug 7, 2012 5:37 PM in response to Toltje

I have to agree with Toltje. Use of a third party app does not solve the issue, though it is a TEMPORARY solution. The issue was never present in Lion but now is in Mountain Lion. This cannot be the intended behaviour of the sleep function.


Not only does EVERYTHING stop when entering sleep (downloads; media conversion; etc) but ALL of my USB drives eject. Upon waking I receive numerious notifications that the drives were not ejected properly (this issue has been raised in another thread). These issues occur even though I did a fresh install of ML.

Oct 18, 2012 2:56 AM in response to Toltje

I have submitted the question on the sleep issue to bugreports and Apple has confirmed the following:


"Apps need to use power assertions while engaged on activities that should not be interrupted and we are working to evangelize this.


For you an interim solution would be to use "pmset noidle" in Terminal."

this is not what I want because pmset noidle will just prevent the mac from sleeping but will not resolve the issue. And the evangelization stuff may be quite long before any single programmer decides it's useful to update their software.


So I have studied a workaround which is working quite well, at least for me - you may want to try this out and let me know.


First of all, I have created a bash script that checks CPU usage and lowers a counter each time the mac is in idle state (i.e. Idle CPU reaches at least 93%). When the counter reaches 0 (which means, after 10 minutes of inactivity), the mac goes to sleep with the pmset sleepnow command.


#!/bin/sh


# forcesleep.sh

#

#

# Created by Luca on 16/10/12.

#

minuti=$(cat /Users/luca/.minutes)

valore=$(top -F -R -o cpu -l 3 | grep "CPU usage" | tail -n 1 | awk -F"," {'print $3'} | cut -d"." -f 1)

if [ $valore -gt 93 ]

then

minuti=$((minuti-2))

echo $minuti >/Users/luca/.minutes

else

minuti=10

echo $minuti >/Users/luca/.minutes

fi

if [ $minuti -eq 0 ]

then

echo 10 >>/Users/luca/.minutes

pmset sleepnow

fi


I have then created a LaunchAgent .plist which is called every two minutes:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.luca.forcesleep</string>

<key>ProgramArguments</key>

<array>

<string>/Users/luca/scripts/idlesleep.sh</string>

</array>

<key>Nice</key>

<integer>1</integer>

<key>StartInterval</key>

<integer>120</integer>

<key>RunAtLoad</key>

<true/>

<key>StandardErrorPath</key>

<string>/tmp/sleeperror.txt</string>

<key>StandardOutPath</key>

<string>/tmp/sleepout.txt</string>

</dict>

</plist>


The plist runs every 120 seconds (2 minutes) and executes the bash script I explained before which is located in my home folder, /Users/luca/scripts/idlesleep.sh.

Change "luca" with your home folder name!


You have to save the plist under $HOME/Library/LaunchAgents

My .plist is named com.luca.forcesleep.plist - the name is in the <string>..</string>


Once everything is setup, just run from terminal the following command:


launchctl load $HOME/Library/LaunchAgents/com.luca.forcesleep.plist (or the name you have given to the plist file) and that's it.


You may want to play around with value 93 which is the threshold between idle state and active state and may be different from mac to mac.

Jan 20, 2014 11:26 AM in response to ClayG

Sadly, I have to agree with the original poster that these "solutions" are no solutions at all. It's one thing to use something like Caffeine while you're there sitting at the computer or have a rendering job to do and will come back after it's one. It's quite another to have a multiple unit XBMC setup around your house that uses NFS (because SMB2 wasn't supported on older versions of XBMC and newer XBMC isn't available for older Apple TVs without wiping the original interface) and Apple simply IGNORES NFS as a networking protocol when it comes to sleep. The PROBLEM is on Apple's side. They IGNORE NFS like it doesn't exist even while they update it to the latest version internally. Why the heck it's not available in "Sharing" with SBM and AFS is just utterly beyond me. I had to manually set it up, which wasn't difficult and works great until OSX decides to put the computer to sleep while XBMC is streaming a video from another side of the house. The very idea of having to walk from one end of the house to the other (let alone with multiple remote viewing boxes and multiple people trying to figure out whether sleep is disabled or not) just to keep turning sleep on or off is absurd when Apple should simply recognize NFS access as an assertion like it does for AFP and SMB. It's just that simple. Sadly, the only "good" workaround is to simply never use Apple's awful SLEEP implementation or just put it into sleep manually when you're not using the computer for long periods of time).


The ironic thing is that if the server is already asleep, XMBC will wake the server from NFS, but if it falls asleep while watching a video via NFS, it won't wake up again from that unit. That makes even less sense. The computer is set to "wake on network access" which OUGHT to mean if there's any amount of networking going on at all (downloading, you name it), it should NOT go to sleep. Apparently, it doens't work right.

Mountain goes to sleep when streaming video

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.