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?
Best Answer
launchd
(ref) is the preferred method for scheduling events in OS X, as opposed to usingcron
.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
namedsleepnow.sh
:Then create a
launchd
plist file for scheduling a script to be run daily. It would look like this:You would probably want to put this in
/System/Library/LaunchDaemons/
with the filenameorg.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. Thepmset sleepnow
command causes the computer to go to sleep immediately without an alert.