Php Script As Cron Job?

liunx

Guest
I'm not sure if "scripting talk" is quite the right place for this one, but I'll try anyway. I'd like to use <a href="http://www.cementhorizon.com/projects/mt-blacklist-autoupdate/" target="_blank">this php script</a> to automatically update my movabletype comment spam blacklist from the master list hosted by the author of <a href="http://jayallen.org/projects/mt-blacklist/" target="_blank">mt-blacklist</a>. The script seems to work when I execute it via the web, but its ideal use is as a cron job.<br /><br />Not thinking through it quite completely, I simply added the script as a cron job to run at midnight, and received the following email from the cron daemon when it attempted to run the script:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->mt-blacklist-autoupdate.php: line 1: ?php: No such file or directory<br />mt-blacklist-autoupdate.php: line 2: /aquota.user: Permission denied<br />mt-blacklist-autoupdate.php: line 4: mt-blacklist-autoupdate: command not found<br />mt-blacklist-autoupdate.php: line 5: syntax error near unexpected token `newline'<br />mt-blacklist-autoupdate.php: line 5: `Author: Gene Wood <gene_wood@***.net>'<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />I don't think there's any personally-compromising info in that excerpt; I trimmed the script's path, just in case... But it really just consists of the errors that cron gets when it tries to execute the script, line by line, as if it were a shell script -- my bad, it's PHP! Doh! I should have realized that it wouldn't work.<br /><br />So, if I change the cron command to "<b>php</b> /path/to/mt-blacklist-autoupdate.php" will it work correctly?<!--content-->
Pretty sure that's the trick: if you start the cron job with "php" and then follow it with the absolute path to the script, you're in good shape.<!--content-->
Yep, t hat did it -- thanks, Rklau!<br />-Alan<!--content-->
 
Back
Top