Running a cron job on a Windows server

Possible duplicate:
What is the cron version for windows?

Hello to all,

I have script.php on the IIS server and I want to call this script automatically every x minutes. The problem is that I need to pass the arguments to the script, as I would do in the browser (script.php? Task = aaa) . Does the scheduled task seem to ignore the argument? task = aaa ...

How can I run this script by passing it some "GET" arguments?

Thanks L

+4
source share
3 answers

You can pass parameters to a file by calling it like this:

C:\PHP5\php.exe -f "C:\PHP s\script.php" -- -arg1 -arg2 -arg3 

and then you can parse argv with this function:

 function arguments($args ) { $ret = array( 'exec' => '', 'options' => array(), 'flags' => array(), 'arguments' => array(), ); $ret['exec'] = array_shift( $args ); while (($arg = array_shift($args)) != NULL) { // Is it a option? (prefixed with --) if ( substr($arg, 0, 2) === '--' ) { $option = substr($arg, 2); // is it the syntax '--option=argument'? if (strpos($option,'=') !== FALSE) array_push( $ret['options'], explode('=', $option, 2) ); else array_push( $ret['options'], $option ); continue; } // Is it a flag or a serial of flags? (prefixed with -) if ( substr( $arg, 0, 1 ) === '-' ) { for ($i = 1; isset($arg[$i]) ; $i++) $ret['flags'][] = $arg[$i]; continue; } // finally, it is not option, nor flag $ret['arguments'][] = $arg; continue; } return $ret; }//function arguments 

Source: http://php.net/manual/en/features.commandline.php

+4
source

I have two cron jobs similar to these on my Windows 2003 server. I am programming a schelude iexplorer task with a URL that I can work with.

For instance:

"C: \ ProgramFiles \ Internet Explorer \ iexplore.exe" http://mydomain.com/admin/index.php?action=central_alertas.php&act=1

+6
source

I would suggest downloading cURL for Windows , as it can make a page request to your server for you. You can then use the Windows Task Scheduler to execute curl script.php?task=aaa .

+3
source

All Articles