Skip to main content
1 of 1
TJ Luoma
  • 20.7k
  • 9
  • 70
  • 112

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" "">
<plist version="1.0">

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/ 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:



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


save that as '/usr/local/bin/' (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?

Boom. Done.

No launchd. No cron. No AppleScript.

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

TJ Luoma
  • 20.7k
  • 9
  • 70
  • 112