1 of 1

Ok, well, here's how you would make launchd run at 2:05 p.m.

Copy this using a text editor and save it as ~/Library/LaunchAgents/com.tjluoma.quit-at-time.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.tjluoma.quit-at-time</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/killMathematica.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>14</integer>
        <key>Minute</key>
        <integer>5</integer>
    </dict>
</dict>
</plist>

Note that you'll need to logout/login or use launchctl load ~/Library/LaunchAgents/com.tjluoma.quit-at-time.plist

Now, the /usr/local/bin/killMathematica.sh line could point to whatever it is you want to run: an app, an AppleScript, or a shell script.

The easiest solution is a shell script:

#!/bin/zsh

APP='Mathematica'

PID=$(ps cx | fgrep "$APP" | awk '{print $1}')

    # if $APP isn't running, then just exit already
[[ "$PID" == "" ]] && exit 0

    # if we get here, then $APP is running
    # tell it to quit using AppleScript
    # if this exits properly, the script will exit too
osascript -e "tell application \"$APP\" to quit" && exit 0

    # if we get here, AppleScript didn't work, so let's try
    # sending the app a 'kill' message
kill -QUIT "$PID" && exit 0

exit 1

# EOF

save that as '/usr/local/bin/killMathematica.sh' (or wherever) and make it chmod 755

Test it out and see if it works.

Now that I've given you the answer to the question you asked

Here's a better solution: use Keyboard Maestro. It's much easier.

How easy?

http://images.luo.ma/Keyboard_Maestro_Quit_at_Specific_Time-20120717-195546.jpg

Boom. Done.

No launchd. No cron. No AppleScript.

(I had to use VLC instead of Mathematica because I don't have Mathematica installed.)