LaunchDaemons on MacOSX
On MacOSX 10.4.x or greater version, you can not use cron daemon to execute scheduled commands.
You have to use launchd.
Add plist under /System/Library/LaunchDaemons.
First string belongs to the key "Label" is unique ID of Daemon process.
The array of "Program Arguments" is the command you want to execute.
And "StartCalendarInterval" is date and time of the scheduled command.
After setting plist, enter the command to load plist.
# launchctl load -w NAMEOFPLIST
And check if the plist was surely loaded,
# launchctl list
Unload plist,
#launcctl unload -w NAMEOFPLIST
Here is a sample plist.
----------------------------------------------------
<?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>named0309</string>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>ProgramArguments</key>
<array>
<string>/Users/Applications/YOURCOMMAND</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>37</integer>
<key>Hour</key>
<integer>14</integer>
<key>Day</key>
<integer>12</integer>
<key>Month</key>
<integer>4</integer>
</dict>
</dict>
</plist>
Category
MacOSXTrackback(0)
Trackbacking Blog List : LaunchDaemons on MacOSX
Trackback URL: http://mentalposition.com/mppweblog/mt-tb.cgi/154
Mac OS X Server で cron が動かなくて往生こいたことがあったけど、launchd いじらなきゃならならなかったのか。
そうそう。
以前、自分もはまって、cronまわりが変更されたことはわかったものの、面倒だったからそのままにしてたんだけど、今回は、対応できない時間帯にDNS更新があったので、調べてみました。