Wednesday, September 17, 2008

Recurring jobs, launchctl, plist, and shell scripting on OSX

OSX is Unix - similar, and yet dissimilar to linux. I'm setting up a few recurring maintenance scripts

First of all, cron is deprecated in favor of launchd, which handles a lot more than just cron jobs.

First, recurring jobs are located in /Users/username/Library/LaunchAgent/ as .plist files.

Sample syntax of a .plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://">
<plist version="1.0">

Alternative interval for daily

Activate the job using the command launchctl load /Users/username/Library/LaunchAgents/plistname.plist

Deactivate the job the same way (except use unload)

No comments: