Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I launch an app in Automator periodically, like in 15 minute intervals?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You can also use AppleScript instead (/Applications/Utilities/AppleScript\ Editor.app/).

The following script starts the Terminal.app every seven seconds:

on idle
    tell application "System Events"
        tell application "Terminal"
            run
        end tell
        return 7
    end tell
end idle

Save this script as an application and let it "stay open after run handler".

share|improve this answer
    
Thank you, this helps! What happens if the app is already running and doing some work? Will it be interrupted? –  Zoltán Matók Oct 2 '12 at 10:40
    
I tried your solution and it works, sort of... In the mac application I try to run I put an [NSApp terminate:self] method so that it quits itself after its job is done. When I run the script it successfully launches the applications and it will do its job and quit. When the script fires again it will throw a "connection is invalid" error, which as I read means that the script tried to communicate with an application that stopped running while the script was being executed. How can I avoid this? –  Zoltán Matók Oct 2 '12 at 11:32
    
@ZoltánMatók I'm sorry, but I can't exactly follow the problem your describing. Why would the Apple Script fire this connection error? I've been using variations of this apple script for different applications without problems. So I'd expect the problem to lie within your described mac application. Maybe you should open a separate question on Stackoverflow? –  gentmatt Oct 2 '12 at 13:35
1  
Thanks, I did! Here's the link if you are interested apple.stackexchange.com/questions/66007/… –  Zoltán Matók Oct 2 '12 at 14:23
    
@ZoltánMatók Yeah, I found it already ;) I upvoted it as soon as I saw it. –  gentmatt Oct 2 '12 at 14:27

Using launchd, you could save the property list below as ~/Library/LaunchAgents/com.stackexchange.apple.65970.plist, and then load it with launchctl load ~/Library/LaunchAgents/com.stackexchange.apple.65970.plist or by logging out and back in.

<?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">
<dict>
    <key>Label</key>
    <string>com.stackexchange.apple.65970</string>
    <key>ProgramArguments</key>
    <array>
        <string>open</string>
        <string>-jga</string>
        <string>Mail</string>
    </array>
    <key>RunAtLoad</key>
    <true/> <!-- run before the first 15 minutes have passed -->
    <key>StartInterval</key>
    <integer>900</integer>
</dict>
</plist>

open -g opens an application on the background, but it will still open a visible window if the application wasn't running before. -j also hides the application if it wasn't running. It was added in 10.8 and is only shown in the help message.

You could also add a line like this to a crontab:

*/15 * * * * open -jga Mail
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.