View Full Version : Scheduled Task > Batch File > PHP Script

09-23-2003, 09:20 PM
I'm trying to run a PHP script through a Windows scheduled task. I set up a batch file reading:

c:\php\php.exe cron.php
'cron.php' being the script I want to run in the task.

The script works in a browser but gives me errors when I see it run in the console. All the script does is connect to a database delete some records from temp databases and writes a log file. The log files write but it never connects to the database. It yells 'Unable to connect to XXX.XXX.XXX.XXX on line XX. Why would it work in the browser, but not the batch file?


09-23-2003, 10:33 PM
do you have mysql (assuming you are using mysql) running when the task is run?

09-24-2003, 05:03 PM
chmod file list

explain countries & tables

does your script rely on any server variables , eg $_SERVER['PHP_SELF'] , $_SERVER['DOCUMENT_ROOT'] etc ?
or $_GET or $_POST data ?? remember these are not always available in the CGI binary
(some $_SERVER variables are in the cli binary though I think)

if you want to pass any variables to the script use $argc & $argv variables
.. /path/to/script.php arg1 arg2 arg3

09-26-2003, 04:49 PM
Its MSSQL and no I don't pass any arguments to the script. It's all runs internally.