2

It's about a Mac mini connected to a touchscreen running at a public school, displaying a browser in kiosk mode. I want the Mac to go to scheduled sleep after school is over.

Energy Saving PrefPane lets me set up a sleeping schedule. When the time has come that scheduled sleep should start, a prompt is displayed with that message mentioned in the subject, counting from 10min to 0 plus allowing users to abort that process.

To prevent anyone from aborting that process I'ld like to cut that message and send the Mac to sleep immediately when the time has come.

Is there any possibility to leave that message out?

Or any other alternatives?

2 Answers 2

2

launchd (ref) is the preferred method for scheduling events in OS X, as opposed to using cron.

Here is a method for putting an OS X computer to sleep at a specified time using built in OS X tools without the override alert prompt. Waking the computer up can still be handled via System Preferences → Energy Saver → Schedule.

First create the following shell script in /usr/local/bin named sleepnow.sh:

#!/bin/sh
pmset sleepnow

Then create a launchd plist file for scheduling a script to be run daily. It would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>org.myschoolname.sleep</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>/usr/local/bin/sleepnow.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>14</integer>
        <key>Minute</key>
        <integer>00</integer>
    </dict>
</dict>
</plist>

You would probably want to put this in /System/Library/LaunchDaemons/ with the filename org.myschoolname.sleep.plist. Adjust the time and name as needed.

You can load the plist using the command sudo launchctl load -w /System/Library/LaunchDaemons/org.myschoolname.sleep.plist or reboot the computer and it should be loaded on system startup.

If you are not comfortable with using launchd files and command line tools then search for the paid OS X app named Lingon which handles the creation of the plist file and loaded it.

Here is a good reference on pmset, which is the command line tool for managing power setting in OS X.

Although pmset can be used to set sleep and wake schedules, you'll still get that alert box on scheduled sleep. The pmset sleepnow command causes the computer to go to sleep immediately without an alert.

1

You could run a cron job that puts the Mac to sleep at a certain time each day. This would simply cause the Mac to just go black, directly to sleep, without any sort of warning at a specified time.

SleepNow is a Unix binary that puts the Mac to sleep immediately

Cronnix is a free GUI for setting cron jobs

Download both. Move Cronnix to your /Applications folder and SleepNow to a folder of your choosing. Open Cronnix and create a new job, set the time parameters and in the "command" field enter the location of the SleepNow binary. Assuming all is set properly the Mac will go directly to sleep, without any warning or prompts, at the times you specified.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .