Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2008
  • Last Modified:

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
0
fixitben
Asked:
fixitben
  • 5
  • 2
1 Solution
 
zoofanCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now