How to register an agent with launchd
Posted
by Konrad Rudolph
on Super User
See other posts from Super User
or by Konrad Rudolph
Published on 2010-04-14T09:27:00Z
Indexed on
2010/04/14
9:33 UTC
Read the original article
Hit count: 617
I’m unable to schedule a periodic launch with launchctl
/launchd
on OS X (Leopard). Basically, I’m unable to find a step-by-step list of instructions on the web and the intuitive approach doesn’t work.
The sync.plist
file:
<?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>net.madrat.utils.sync</string>
<key>Program</key>
<string>rsync</string>
<key>ProgramArguments</key>
<array>
<string>-ar</string>
<string>/path/to/folder/</string>
<string>/path/to/backup/</string>
</array>
<key>StartInterval</key>
<integer>7200</integer>
</dict>
</plist>
I’ve put this script inside the path ~/Library/LaunchAgents
.
Next, I’ve registered the script using
launchctl load ~/Library/LaunchAgents/sync.plist
Finally, to test that it works, I started the job:
launchctl start net.madrat.utils.sync
– Nothing happened. Manually executing the rsync
command in the terminal yields the expected result.
I’m fairly sure that the job was registered correctly because if I try to start a non-existing job, I get an error message (which I didn’t get in the above command).
What did I do wrong?
© Super User or respective owner