I have created this launchctl .plist for opening an application at a specific time every day – or the next time the computer wakes from sleep.

<?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">

The above is supposed to wake app Caffeine at 7:40 AM Every day.

However, can I also include a clause to make the application terminate at 00:00 AM Every day if the computer is awake?

Meaning, is there an opposite to StartCalendarInterval, or would I have to go about it some other way, .e.g. via crontab?


One of these two methods should work, but I admit I have not tested them:

  1. Either you could write an AppleScript a la

tell application "Caffeine" to quit

put this in a file, then either launch the file from an osascript command or put it into Script Editor and save it as an application and launch that as a an app

  1. or you could use the good old killall command. You would have to lookup the name of process of the Caffeine process and send it a

    killall Caffeine

command, assuming that the process name of the Caffeine app is Caffeine (check it from the Activity monitor or the ps command)

| improve this answer | |
  • Thanks for your reply. I think the first method will work nicely whereby launchctl runs an AppleScript via osascript. – PAN Mar 9 '16 at 16:46

You must log in to answer this question.

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