Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Remotely prevent computer from sleeping?

Remotely prevent computer from sleeping?
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 09:32 AM
 
Is there a way to prevent my computer from sleeping if I am logged in remotely?

kman
     
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Oct 10, 2006, 09:44 AM
 
pmset perhaps

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 10:12 AM
 
Cool. Thanks. That is most helpful.

Is there a way to automatically prevent sleep when users are logged in remotely? I don't log in that often, but it seems like a hassle to change pmset when I log on so that it won't sleep and then changing it back when I log off. A script would work, I suppose, but it requires root access and I would prefer to log into a standard account remotely rather than an admin account.

kman
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Oct 10, 2006, 10:19 AM
 
Originally Posted by kman42
Cool. Thanks. That is most helpful.

Is there a way to automatically prevent sleep when users are logged in remotely? I don't log in that often, but it seems like a hassle to change pmset when I log on so that it won't sleep and then changing it back when I log off. A script would work, I suppose, but it requires root access and I would prefer to log into a standard account remotely rather than an admin account.

kman

Why not just disable sleep on this machine?

Can you run pmset as a regular user? If so, how about a crontab invoking pmset to keep the machine from sleeping?
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 11:08 AM
 
pmset must be run as root.

Well, since I don't log in that often I would rather not leave the machine running all the time, both for energy-saving reasons and just to help it last longer.

If pmset is the only way, then I suppose that I can log in with an admin account and use a login script to run pmset to keep the machine awake and a logout script to put it back to its original state. Any other ideas?

kman
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Oct 10, 2006, 11:21 AM
 
Originally Posted by kman42
pmset must be run as root.

Well, since I don't log in that often I would rather not leave the machine running all the time, both for energy-saving reasons and just to help it last longer.

If pmset is the only way, then I suppose that I can log in with an admin account and use a login script to run pmset to keep the machine awake and a logout script to put it back to its original state. Any other ideas?

kman

Why use a login script? You'd just be reinventing the wheel... scheduled tasks already exist in cronjobs/crontabs, and setting up a cronjob would take a fraction of the time necessary as well in crafting a script.
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 11:50 AM
 
I don't understand how a crontab would help me. Then I would just be executing a pmset at specific times during the day. I need to suspend sleep mode during times when I am logged in. I don't think it helps me to run pmset at 10am and set sleep for four hours. I could just do that through the system prefs. I must be misunderstanding your proposed strategy. Could you elaborate?

Currently, I have my computer set to sleep after 2 hrs. This way if I get to work and realize I needed to log into my home computer, I can do so. Although if I don't realize it within the first two hours I'm SOL (but I am working on trying one of the wakeonlan web sites to resolve this). Once I get logged in, I would like to suspend sleep so that I can work for more than two hours.

I have the same setup on my work computer so that I can log in from home, but only within two hours of leaving work.

I think you have a solution in mind, but I am just not getting it. Any further elaboration would be great.

kman
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 11:58 AM
 
I found this little app:
Jiggler : Protect your Mac from sleep and screensavers

Perhaps I can just run it from the command line when I log in and quit it right before logging out. Hmmm...
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 12:22 PM
 
Originally Posted by kman42
I found this little app:
Jiggler : Protect your Mac from sleep and screensavers

Perhaps I can just run it from the command line when I log in and quit it right before logging out. Hmmm...
On second thought, this won't work well on my work computer because I would prefer to have the screen locked...
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Oct 10, 2006, 12:49 PM
 
Originally Posted by kman42
I don't understand how a crontab would help me. Then I would just be executing a pmset at specific times during the day. I need to suspend sleep mode during times when I am logged in. I don't think it helps me to run pmset at 10am and set sleep for four hours. I could just do that through the system prefs. I must be misunderstanding your proposed strategy. Could you elaborate?

Currently, I have my computer set to sleep after 2 hrs. This way if I get to work and realize I needed to log into my home computer, I can do so. Although if I don't realize it within the first two hours I'm SOL (but I am working on trying one of the wakeonlan web sites to resolve this). Once I get logged in, I would like to suspend sleep so that I can work for more than two hours.

I have the same setup on my work computer so that I can log in from home, but only within two hours of leaving work.

I think you have a solution in mind, but I am just not getting it. Any further elaboration would be great.

kman

The crontab strategy would simply prevent the machine from sleeping which you could setup without GUI access.

Perhaps the misunderstanding is mine, I apologize for not realizing that you only want this to be active when you've logged on.

Honestly, if you want my opinion, if this machine is essentially a server and handles important enough functions, I'd just disable sleep. Servers don't like to sleep or power down, creating this extra layer is probably only going to create problems for you.

If you want to save power, simply have your display sleep. Your display consumes the vast majority of the machine's power, the power needed just to keep the OS responsive is a relative drop in the bucket. I don't think you will be preserving the longevity of your machine by having it sleep more frequently.
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 10, 2006, 01:23 PM
 
Well, after reviewing some discussions on sleep/power/energy savings, I've decided to leave my computer awake most of the time with the hard drive shutting down when possible and the display turning off after 30 minutes. I then scheduled the computer to go to sleep at midnight and wake up at 7am. I can't think of the last time I was awake and using my computer during those hours.

Thanks for all the advice.

kman
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Oct 10, 2006, 01:39 PM
 
How about activating `wake-up on LAN': shouldn't the computer never go to sleep as long as there is network activity?
I don't suffer from insanity, I enjoy every minute of it.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Oct 10, 2006, 01:47 PM
 
Originally Posted by kman42
Well, after reviewing some discussions on sleep/power/energy savings, I've decided to leave my computer awake most of the time with the hard drive shutting down when possible and the display turning off after 30 minutes. I then scheduled the computer to go to sleep at midnight and wake up at 7am. I can't think of the last time I was awake and using my computer during those hours.

Thanks for all the advice.

kman

Just FYI, I've had problems with the hard drive not spinning up when needed on various hardware and past OS revisions. YMMV.
     
Senior User
Join Date: Nov 2000
Location: Toronto, Ontario
Status: Offline
Reply With Quote
Oct 10, 2006, 02:40 PM
 
I have my old PMG4 set up as a file server, and it's set to sleep after 10 mins of inactivity. However, if I connect to it through AFP, the machine stays awake so long as the drive is mounted on my Powerbook. When I unmount it, the machine goes to sleep after a minute or two if not instantly.

Oh and I should mention that I've checked on the "Wake on administrator access" option in the Ethernet network panel. I simply use Wake On Mac to wake the machine remotely whenever i need to connect to it.
     
XXV
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 26, 2006, 09:11 AM
 
Originally Posted by OreoCookie View Post
How about activating `wake-up on LAN': shouldn't the computer never go to sleep as long as there is network activity?
I just stumbled on this post via Google. For reference, "wake on LAN" doesn't keep a computer awake if there is network activity. Instead, it will wake a computer up when a "magic packet" is sent to the computer's ethernet port. That magic packet can be encapsulated in any ethernet packet including UDP (which most "wake on LAN" programs seem to use).

It's very useful if you wish to wake up a computer remotely... you can even open up a port in your firewall (or perhaps even use an existing one) to send the wakeup packet. The magic packet is constructed using the computer's MAC address, so that means that it's even relatively secure (not that being able to wake up someone's computer is really a security hole).

Thanks for the tip regarding "pmset". I'm trying to do a similar thing to kman42 and may simply go with the "leave it awake, but low-power" method.
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Oct 26, 2006, 09:44 AM
 
Originally Posted by XXV View Post
I just stumbled on this post via Google. For reference, "wake on LAN" doesn't keep a computer awake if there is network activity. Instead, it will wake a computer up when a "magic packet" is sent to the computer's ethernet port. That magic packet can be encapsulated in any ethernet packet including UDP (which most "wake on LAN" programs seem to use).
I'm aware of that. But if someone is logged in remotely, there will be some network activity and hence, the computer shouldn't go to sleep.
I don't suffer from insanity, I enjoy every minute of it.
     
XXV
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 30, 2006, 08:31 AM
 
Originally Posted by OreoCookie View Post
I'm aware of that. But if someone is logged in remotely, there will be some network activity and hence, the computer shouldn't go to sleep.
I don't believe that this is the case. It certainly didn't work for my girlfriend who was disconnected when the computer fell asleep on her (she SSH'd into the machine and then SSHing out of it to a remote machine).

There's so much idle network traffic on a modern computer that I don't think this would be a successful feature. Think of all the Dashboard widgets that read from the network in the background, update checks that run, etc.
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Oct 30, 2006, 10:12 AM
 
Originally Posted by XXV View Post
I don't believe that this is the case. It certainly didn't work for my girlfriend who was disconnected when the computer fell asleep on her (she SSH'd into the machine and then SSHing out of it to a remote machine).

There's so much idle network traffic on a modern computer that I don't think this would be a successful feature. Think of all the Dashboard widgets that read from the network in the background, update checks that run, etc.
That's why I said I wasn't sure whether this would would work. However, with ARD, there might be constant traffic (unlike with ssh) … 
I don't suffer from insanity, I enjoy every minute of it.
     
XXV
Fresh-Faced Recruit
Join Date: Oct 2006
Status: Offline
Reply With Quote
Oct 30, 2006, 10:42 AM
 
Originally Posted by OreoCookie View Post
That's why I said I wasn't sure whether this would would work. However, with ARD, there might be constant traffic (unlike with ssh) …
I don't think constant traffic would make much of a difference in any "network traffic keeps the machine awake" scheme. Network traffic is measured in the difference in the number of packets sent and/or received in a given (generally very small) time window. That means two schemes are possible (of course, there could be more complex ones than these):

1) At the instant the machine is scheduled to fall asleep, if there is network traffic, the sleep is aborted. This could be a pause in network activity during a very high amount of network traffic (in the very small time window that network activity is measured), so this scheme would not work.

2) Any network traffic at all resets the "time to fall asleep" timer. If I tell my machine to "be awake for an hour and sleep as needed", any traffic within that hour will prevent it from sleeping. Again, this will not work due to background network activity.

This is why I do not believe that Apple has set it up so that network traffic will keep a machine from falling asleep.

It would make more sense for the machine to detect what type of network traffic is going in / out (detect SSH or ARD connections and prevent sleeping when they are open), but again - I don't believe that is the case.

However, I would not be surprised if ARD prevent the machine from sleeping, but that would be based on other things than simply network activity. If that is the case, Apple should make it so SSH works in the same way.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:38 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2