PDA

View Full Version : executing php files with cron jobs


amalanow
09-15-2007, 11:35 PM
I have a PHP file that I want to execute via a cron job. The php file pulls information from a database and sends an email if it finds a condition to be true. I can execute the page just fine in my browser and it does what it should, but when I set up a cron job to do it, I get an error emailed back at me. Here is what I get as an error:

"/home/username/public_html/architecture/emailcheck.php: line 1: ?php
: No such file or directory
/home/username/public_html/architecture/emailcheck.php: line 2: syntax error near unexpected token `('
/home/username/public_html/architecture/emailcheck.php: line 2: `$yesterdaysql1 = time() - (1 * 24 * 60 * 60);
'

Does anyone know how I can get a cron job to execute my php file?

siguie
09-16-2007, 03:24 AM
It could be a few things ... are you using a cron command line that looks something like ...

wget -q -O /dev/null http://www.domain.com/file.php

Does the webpage pass any variables to your script? If so they may not be getting defined properly without a browser.

Good Luck!