Power Manager can schedule AppleScripts to run regularly, as part of a schedule. The Schedule Assistant includes tasks to help create events that will run your AppleScript daily, on specific dates, or after a period of inactivity.
The best way to schedule your AppleScript, is to create an event and include the AppleScript within the event itself. This removes any need for a separate AppleScript file. Your Power Manager event can be shared with others, and moved from Mac to Mac without needing additional files.
Create a Scheduled AppleScript
- Launch System Preferences and select Power Manager.
- Click "Add…" to create a new event.
- Choose the template "Run a script daily".
- Copy and paste your AppleScript into the "Script" step.
- Add the following 'hash-bang' line to the top of your script:
The hash-bang line tells Mac OS X what program should be used to run your script. In this case, we use osascript to run your AppleScript.
Other hash-bang lines would allow you to write scripts in other languages, such as perl, ruby, or shell script.
- Continue through the remaining steps until your event is created.
Your AppleScript is now scheduled and ready to run. The Schedule Assistant has created an event that will run your AppleScript in the front most user's session.
If needed, Power Manager will automatically wake up your Mac in order to perform your AppleScript. Thanks to Power Manager, you have one less reason to leave your Mac running any longer than necessary.
Your event has been marked as having on-demand behaviour. Administrators on your Mac can trigger your AppleScript at any time. You can do this through the Power Manager status menu or via the command line tool pmctl.
To share your AppleScript event, click and drag the event from Power Manager onto your desktop. The resulting file can be e-mailed to friends or colleagues.