Scripting for OSX: repeating job

I collect little quotes and funny thoughts and have them randomly shown below my mail, one at a time. Over the years I have done this in a number of ways, but never found a really practical solution other than running a dedicated program, when I was on Windows. I was never able to find a proper solution for OSX.

The only way forward was writing a shell script. This was relatively easy and I found some easy hints for selecting a line from one file and inserting it is another HTML/text file. Let’s just say I never bothered to understand ‘sed’ but copy-pasted a nice solution from the ‘Net.

The problem was that I want to repeat the job every 15 seconds or so, to create a new tag-line over and over again. The script I found did it with an infinite loop and a sleep=command. Not the nicest way, to put it mildly. The other obvious reason is creating a cronjob, but it seems OSX has a better solution for running scripts repeatedly.

The trick is to create a plist file. It is a bit of a weird crossover between an XML and a property file (i.e. order matters!), but the syntax is straightforward. And by adding the <StartInterval> you control the number of seconds the app is restarted. Easy!

So my plist file is

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “”>
<plist version=”1.0″>



The next step is to copy this file to ~/Library/LaunchAgents and the next time you login (or restart?) the script runs.

An easy solution, out of the box, when you know what to look for on OSX.

2 responses to “Scripting for OSX: repeating job”

  1. How do I add the shadows to a Joomla template?

Leave a Reply