我最近尝试从 PC 上的 cron 切换到在我的 Mac Mini (10.7.5) 上启动。我搜索并认为我的设置正确,但似乎预定的脚本在请求的时间之后显着启动。详情如下。
列表:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>RecordBluesA</string>
<key>ProgramArguments</key>
<array>
<string>/Users/gkd/scripts/script_record_blues_a.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>19</integer>
<key>Minute</key>
<integer>00</integer>
<!-- Test by trying everyday
<key>Weekday</key>
<integer>6</integer>
-->
</dict>
<key>StandardErrorPath</key>
<string>/tmp/RecordBluesA.err</string>
<key>StandardOutPath</key>
<string>/tmp/RecordBluesA.out</string>
</dict>
</plist>
script_record_blues_a.sh :
export DISPLAY=:0.0
script=$0
echo "Starting $script at `date`\n"
date=`date +%Y%m%d`
mplayer -playlist http://wxpnhi.streamguys.com/listen.pls -dumpstream -dumpfile ~/RecordedMusic/${date}_BluesA.mp3 &
PID=$!
# Kill after 2 hours minus a minute
# sleep 7140
# Debug, running for a little
sleep 120
echo "Killing mplayer (PID=$PID) at `date`\n"
kill $PID
echo "Ending $script at `date`\n"
“StandardOutPath”文件的顶部:
Starting /Users/gkd/scripts/script_record_blues_a.sh at Wed Sep 23 19:11:59 EDT 2015
所以好像晚了12分钟。. .
我“launchctl load”它,列表显示它正在等待:
Mon Sep 28 13:33 gkd ~/Library/LaunchAgents: launchctl list|grep -i record
- 0 RecordThistle
- 0 RecordBluesB
- 0 RecordBluesA
- 0 com.apple.coredata.externalrecordswriter
当我手动测试时,将 plist“分钟”设置为未来几分钟,它似乎按预期开始,然后“launchctl 列表”指示非连字符 PID。所以我把所有东西都打包在一起,几天后启用它,然后检查,它没有按时启动,但更像是晚了 20 分钟。有什么想法吗?谢谢。