How to bounce an application with Applescript

Say, for whatever reason, you want to bounce iphoto once an hour. You can do that with AppleScript and cron.

Copy this into ~/bin/bounce-iphoto:

#!/usr/bin/osascript
on appIsRunning(appName)
  tell application "System Events" to (name of processes) contains appName
end appIsRunning 

if appIsRunning("iPhoto") then
  tell application "iPhoto" to quit
  delay 60
  tell application "iPhoto" to run
end if

Then wire it up with cron:

chmod 755 ~/bin/bounce-iphoto
crontab -e

and add this line to your crontab (which may be empty):

0 * * * * $HOME/bin/bounce-iphoto

Related posts:

  1. How to delete an iPhone application
    Click the home button, flick to the page that has the icon of the application or bookmark that you want to remove, and then tap and hold for a second.......
  2. Maildir auto-archive
    If you’ve got your mail sitting on some server and in Maildir format, and you’ve used Outlook’s “Auto Archive” feature, you might wish that your inbox (and subdirectory contents) could......
  3. OpenDNS updater for linux/ubuntu
    The OpenDNS service is great — it provides anti-phishing and the ability to filter out some of the less desirable detritus from the internets. OpenDNS needs to be periodically notified......
  4. 50,000 photos in iPhoto on a shared laptop and external drive
    I’ve got over 100GiB of photos (JPEG and RAW) taken over the years, and they don’t comfortably fit on a laptop. The laptop is also shared by everyone in my......

This entry was posted in Technical HOWTOs and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Additional comments powered by BackType