Forum Moderators: coopster
What I really hope to achieve is a scheduled task that will run in the background without opening a firefox browser or one that will at least close the browser it opens.
In my scheduled tasks run line I have:
C:\PROGRA~1\MOZILL~1\firefox.exe http://www.example.com/tester.php
The line under START IN:
C:\PROGRA~1\MOZILL~1
Any suggestions I greatly appreciate. Thank you anyone and everyone.
[php.net...]
So for example:
C:\php\php.exe -f path\to\your\script.php
Here's the usage of the executable:
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -- [args...]
php [options] -a-a Run interactively
-c <path>¦<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse and execute <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-B <begin_code> Run PHP <begin_code> before processing input lines
-R <code> Run PHP <code> for every input line
-F <file> Parse and execute <file> for every input line
-E <end_code> Run PHP <end_code> after processing all input lines
-H Hide any passed arguments from external tools.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin--ini Show configuration file names
--rf <name> Show information about function <name>.
--rc <name> Show information about class <name>.
--re <name> Show information about extension <name>.
--ri <name> Show configuration for extension <name>.
I tried in the scheduled task run line:
"C:\Program Files\PHP\php.exe - f C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\posting\tester.php"
After I click Apply Then OK. Then in the scheduled tasks window which displays all the scheduled tasks, I'd right click the paticular cron job and click run and it will say Could Not Start?
I was able to run the php script from the cmd line
For Others Information:
1. I moved my cron script (cron.php) to the PHP folder on my system.
2. Then go to START -> RUN -> cmd (this opens the terminal)
3. Then I entered: cd C:\Program Files\PHP\ (this moves commands to the specified directory
4. Then I took your advice eelixduppy, enter: php -f tester.php
5. This successfully runs the script provided that your cron script is updated appropriately with the correct directories (ex. instead of writing to /postings/here.txt, change it C:/Program Files/Apache /full path/here.txt)
Now Step 6. I'm going to try to add your last bits in the scheduled task section and will post results.
I tried these in combinations:
RUN: "C:\Program Files\PHP\php.exe -f C:\Program Files\PHP\tester.php"
START IN: C:\Program Files\PHP\
RUN: "C:\Program Files\PHP\php -f tester.php"
START IN: C:\Program Files\PHP\php
RUN: "C:\Program Files\PHP\php.exe -f tester.php"
START IN: C:\Program Files\PHP\
Still nothing.....please help, my hair is falling out as I type.
I see this:
"php.job" (tester.php) 10/21/2009 5:15:32 PM ** ERROR **
Unable to start task.
The specific error is:
0x80070002: The system cannot find the file specified.
Try using the Task page Browse button to locate the application.
Is it the formatting of the run? Currently Set:
RUN: "C:\Program Files\PHP\php.exe -f C:\Program Files\PHP\tester.php"
START IN: C:\Program Files\PHP\
Try using the Task page Browse button to locate the application.
Seems it cannot find php.exe. Have you tried using the browse method instead of typing it in manually. Perhaps you are missing something.
Thats why START > RUN > CMD can find cmd.exe
you will have to restart the system after adding the location to the path
I was able to remedy the problem as follows:
To make the scheduled task...because for some reason the php.exe wasn't executing the script, I tested it in regular cmd prompt and it worked.
I then created a .bat file and enter this in it run the execution through cmd:
cd C:\Program Files\PHP & php -f cron\icrawl.php & exit
what this is cd -> go to this directory -> php call -> the cron script -> exit
This allows a scheduled task to run now and execute a cron script. I guess the only downside to it is that a cmd window pops open and closes immediately when the scheduled task is automatically carried out, but it doesn't take any focus away from my current screen.
Hope this helps anyone else who stumble upon it. I also got more details from this thread:
[webmasterworld.com...]