Apple - Can I automatically launch an app at a specific time on Mavericks?
The great thing about a specific question is that it can be given a specific answer.
For example, the OP said: "There's an excellent Flickr app called SuprSetr which I'd like to automatically launch each morning at 3:55 am. How?"
Answer: Save the following as com.tjluoma.SuprSetr.plist
(or whatever name you prefer, but it should end with .plist) and put it into the folder ~/Library/LaunchAgents (where ~ is your Home Directory):
<?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>AbandonProcessGroup</key>
<true/>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.tjluoma.SuprSetr</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-a</string>
<string>SuprSetr</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>55</integer>
</dict>
</array>
</dict>
</plist>
And then, once the file is in place, you should enter this command in Terminal:
launchctl load ~/Library/LaunchAgents/com.tjluoma.SuprSetr.plist
Then it will be ready to launch the app SuprSetr at 3:55 a.m. every day. (Note: if the computer is asleep at 3:55 a.m., it will run when the computer wakes up.)
From that specific example, once you understand that what this plist
file does does is tell launchd
to run the Terminal command:
/usr/bin/open -a SuprSetr
at the hour '3' and the minute '55', then it should be easy to extrapolate from that to other apps that you want to run at other times.
Now, if you want to write these all by hand, you can do that for free, but an app like Lingon is a good choice (I'd recommend not buying the Mac App Store version, as the app seems to me like something that Apple is not going to like in the world of sandboxing, and you'd get a more feature-rich app from the developer.
My personal preference is for an app called LaunchControl which is free to try, and then the developer asks for something reasonable like US$10, but there is no DRM, no license codes, but instead relies on the good ol' honor system. (It’s my hope that people who use it will live up to the developer's faith in that system.)
It looks like Apple has removed the built-in functionality from Calendar. However, there are 3rd party applications that can launch apps automatically at a specified time.
Try Lingon -it works in Mavericks...
The option to open a URL in iCal was actually removed in Mountain Lion, but you can now use Calendar alarms instead:
Using launchd, you could save a plist like this as for example ~/Library/LaunchAgents/openmail.plist
:
<?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>openmail</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>pgrep -x Mail||open -jga Mail</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>55</integer>
</dict>
</array>
</plist>
Then run launchctl load ~/Library/LaunchAgents/openmail.plist
.
A third option is to run EDITOR=nano crontab -e
and add a line like this:
55 3 * * * pgrep -x Mail||open -jga Mail
open -jga
opens an application hidden and usually without raising any windows. For some applications like Mail and TextEdit, it creates and raises a new default window if the application is running but has no visible windows, but you can use pgrep to check if the application is running first.
If you want to open the application on the foreground, use just open -a
.