Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sic

macrumors 6502
Original poster
Oct 26, 2005
321
0
Southampton UK
I've been looking around for the last couple of days and I can't seem to find anything about it. I wanted to set a cron, but apparently launchd has superseded cron. I've found tutorials on scheduling tasks, but nothing that will allow me to execute a php file at a given interval!

has anyone got any info on setting this up? I don't really know where to start :/
 
right, I think I'm getting somewhere with this. could a kind moderator please move this to mac applications?

I've got my command that I want to execute periodically:

Code:
lynx --dump http://localhost/update.php

and I have created a plist (com.jasper.updater.plist) file and put it in ~/Library/LaunchAgents/:

Code:
<?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>com.jasper.updater</string>
	<key>Program</key>
	<string>/Applications/Lynx.command</string>
	<key>ProgramArguments</key>
	<array>
		<string>--dump</string>
		<string>http://localhost/update.php</string>
	</array>
	<key>StartInterval</key>
	<integer>20</integer>
	<key>Debug</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/Users/jasper/Desktop/error.txt</string>
</dict>
</plist>

then run
Code:
launchctl load ~/Library/LaunchAgents/com.jasper.updater.plist

and running launchctl list shows that my plist is there (with a status of 1, which I can't seem to find the meaning of). However, the action isn't being run at all, and I'm not getting any error output to a text file on my desktop. can anyone spot what I'm doing wrong here, as it's driving me a little mad!
 
First, I recommend looking at Lingon to manage your launchd stuff. I had similar headache and it all seemed to go magically away when I found Lingon. Also, check the permissions on your files, perhaps.

Also, my approach would be to put the command(s) in a shell script (executable text file) and run that script, rather than run it as an application or .command. If I recall a .command will open terminal when it is run? A shell script will run without opening terminal.

edit: There may be some confusion between <program> and <ProgramArguments>. Unless you know exactly what they are doing, just ignore the <programArguments> keys entirely if I recall correctly.
 
Thanks, tried that Lingon app but it's incredibly buggy - I just got annoyed with it not saving anything and carried on doing it manually. it's working quite well, but testing a 5 minute interval is quite irritating. I'll probably add some debugging to my bash script to make it a little easier!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.