我最近尝试在PC上从cron切换到我的Mac Mini(10.7.5)。我搜索并认为我的设置正确,但似乎预定的脚本在请求的时间后显着启动。详情如下。
plist中:
<?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"
&#34; StandardOutPath&#34;文件:
Starting /Users/gkd/scripts/script_record_blues_a.sh at Wed Sep 23 19:11:59 EDT 2015
所以看起来好像迟到了12分钟。 。
我&#34;启动加载&#34;它,列表显示它在等待:
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&#34; Minute&#34;在未来的几分钟内,它似乎在预期的时候开始,以及&#34; launchctl list&#34;然后表示非连字符PID。所以我把所有东西都包在一起,然后启用了几天,之后再检查,它没有准时开始,但是太晚了20分钟。什么错误的想法?感谢。
答案 0 :(得分:0)
当工作开始时,Mac正在“睡觉”。所以现在我不让它睡觉,一切正常。