I recently tried to switch to launched on my Mac Mini (10.7.5) from cron on a PC. I searched and think I have things set up right, but it seems that the scheduled script starts significantly after the requested time. Details below.
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"
Top of the "StandardOutPath" file:
Starting /Users/gkd/scripts/script_record_blues_a.sh at Wed Sep 23 19:11:59 EDT 2015
So it seems like 12 minutes late . . .
I "launchctl load" it, and a list shows it waiting:
Mon Sep 28 13:33 gkd ~/Library/LaunchAgents: launchctl list|grep -i record
- 0 RecordThistle
- 0 RecordBluesB
- 0 RecordBluesA
- 0 com.apple.coredata.externalrecordswriter
When I was testing manually, setting the plist "Minute" to a few minutes in the future, it seemed to start when expected, and the "launchctl list" then indicated non-hyphen PIDs. So I wrapped everything together and enabled it for a few days away, then checked afterwards, and it hadn't started on time, but more like 20 some minutes too late. Any thoughts on what's wrong? Thanks.