To get started with launchd (instead of cron) you'll want to first create an empty .plist
file, for example local.mytask.plist
and put it somewhere. ~/Library/LaunchAgents
is probably a good place. Open that in text editor and copy in the code below
<?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>KeepAlive</key>
<false/>
<key>Label</key>
<string>local.mytask</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/wget</string>
<string>http://someserver/somepage.php</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
<key>RunAtLoad</key>
<true />
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
Then "activate" the file from the command line:
sudo launchctl load /Users/my_username/Library/LaunchAgents/local.mytask.plist
To make it load automatically, create a ~/.launchd.conf
file with the same line (minus sudo launch
)
load /Users/my_username/Library/LaunchAgents/local.mytask.plist
The above instructions above have been copied from www.davidlanier.com and reposted here for your reference.