Archive

Posts Tagged ‘cron like’

How to run php script every 15 minutes with launchd

February 25th, 2011 No comments

On Mac OS X 10.6.6 I wanted a php script to be run every fifteen minutes past the hour , to check if something has been scheduled to run. I tried to use Lingon, but it couldn’t do exactly this. So I searched and found out I had to use an array.

The script below will use wget to run a php script at 00, 15, 30 and 45 minutes, every hour. Put it in /Library/LaunchAgents
and call it something like com.example.phpcheck.plist and restart the Mac.

<?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>no.medieweb.autosend</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/wget</string>
<string>-q</string>
<string>–delete-after</string>
<string>http://example.com/script.php</string>
</array>
<key>ServiceDescription</key>
<string>Check script every 15 minutes</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Minute</key>
<integer>0</integer>
</dict>
<dict>
<key>Minute</key>
<integer>15</integer>
</dict>
<dict>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Minute</key>
<integer>45</integer>
</dict>

</array>
</dict>
</plist>