How do I run an app using launchd at regular intervals?

Solution 1:

Use oascript to call your ApplesScript.

$ oascript foobar.applescript

In your plist your ProgramArguments definition to launch the app would be as follows:

<key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>foobar.applescript</string>
    </array>


To get your item to run, you need a StartInterval definition which takes an integer for the number of seconds (1800 for 30 mins) between runs.

<key>StartInterval</key>
<integer>1800</integer>


A simple but functional plist would look as follows:

<?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.user.foobar.app</string>
   <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>foobar.applescript</string>
    </array>
    <key>StartInterval</key>
    <integer>1800</integer>

</dict>
</plist>