Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

Goodbye cron
I got a new harddrive in my iBook a week or so ago and ever since then I've been without my scheduled cron jobs as I didn't have the time to set them up again.

In OS X 10.4 Apple replaced cron with launchd however. You can still use cron if you like (my desktop still runs all the jobs I set up years ago) but the preferred method of invoking periodic jobs is now the launchd daemon.


Migrating from cron turns out to be pretty easy, just create a plist, which is just an XML file, in the appropriate directory and launchd will do its thing.

See "Getting started with launchd" on the Apple Developer site.

Here's what the plist for my APOD to desktop script looks like:
<?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.haroldbakker.apod</string>
    <key>OnDemand</key>
    <false/>
    <key>Program</key>
    <string>/Users/harold/bin/apod.pl</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/harold/bin/apod.pl</string>
    </array>
    <key>ServiceDescription</key>
    <string>Get the latest Astronomy Picture of the Day and set it as the desktop picture</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>10</integer>
        <key>Minute</key>
        <integer>30</integer>
    </dict>
</dict>
</plist>


This file is called com.haroldbakker.apod.plist and I placed it in the following location: /Users/harold/Library/LaunchAgents (create the LaunchAgents folder if it's not there).

No more messing around with difficult to understand crontabs, just drop a file into place and launchd will run it when needed.

Show all items | Read all items

About, copyright, privacy and accessibility | Mail