scheduled task php

I am trying to run a scheduled task on windows with a php script.  But I have tried a cmd script and just hard coding it and neither works.  But both run if I do them via command line or just run the cmd script.


Any way I do it I either get a error 0x1 or 0x2 or 0x0.  But no results.


I have tried in cmd script  with start c:\PHP-IIS\php4\php.exe C:\Inetpub\wwwroot\ftpsite\email.php

And just in the run field this start c:\PHP-IIS\php4\php.exe "C:\Inetpub\wwwroot\ftpsite\email.php"

Still no results.

Do you have any answers?

It will run fine by itself but not with the scheduler in windows server 2000.

Any help would be great.

Thanks
Fixitben
LVL 7
fixitbenAsked:
Who is Participating?
 
zoofanConnect With a Mentor Commented:
I belive you need to use the -f switch on php

c:\php5\php.exe -f myscript.php


zf
0
 
zoofanCommented:
From php.net

http://us2.php.net/features.commandline

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               Display colour syntax highlighted source.
  -v               Version number
  -w               Display 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>.

 

The CLI SAPI has three different ways of getting the PHP code you want to execute:

   1.

      Telling PHP to execute a certain file.

      php my_script.php

      php -f my_script.php



zf
           
0
 
fixitbenAuthor Commented:
When I type this c:\PHP-IIS\php4\php.exe -f  "C:\Inetpub\wwwroot\ftpsite\email.php" in the run field I get a 0x2 error.


And in the error log I get this

 "ftp.job" (php.exe)
      Started 8/3/2007 11:27:30 PM
"ftp.job" (php.exe)
      Finished 8/3/2007 11:27:30 PM
      Result: The task completed with an exit code of (2).


And if I put it in a cmd script and run that I get a 0x0 error.

"ftp.job" (ftp.cmd)
      Started 8/3/2007 11:31:03 PM
"ftp.job" (ftp.cmd)
      Finished 8/3/2007 11:31:03 PM
      Result: The task completed with an exit code of (0).

Still no results though.

thanks
Fixitben
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
zoofanCommented:
Sorry thought that would help,  I am sending email via php and a scheduled task but as i notice your running php4 and I have 5 I am also using apache not IIS.  Whish I could help more.  

It does send the email out if you run the script without task scheduler?

zf
0
 
zoofanCommented:
0
 
zoofanCommented:
Logging the output aside from error 0 may help narrow this down some.

zf
0
 
milanmkCommented:
Enable the PHP Error Logging and see if there are any errors in there.

You can do that by changing php.ini in windows folder

log_errors = On
error_log = "c:/phperror.txt"
0
 
fixitbenAuthor Commented:
Well something wierd just happened.  I looked in task manager and saw 5 php.exe running so I killed them.  Then restarted IIS and now it works fine.  
I have no idea why. Unless those rouge php.exe where causing the problem.

Well thanks for your help.

Thanks
Fixitben
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.