在Windows服务器上运行“ cron”作业[重复]。

|                                                                                                                   这个问题已经在这里有了答案:                                                      
已邀请:
        您可以通过调用参数将参数传递给文件,如下所示:
C:\\PHP5\\php.exe -f \"C:\\PHP Scripts\\script.php\" -- -arg1 -arg2 -arg3
然后您可以使用以下函数解析argv:
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
来源:http://php.net/manual/en/features.commandline.php     
        我在Windows 2003 Server上有两次像这样的Cron作业。我使用可以工作的URL编写了一个iexplorer的简单任务。 例如: \“ C:\\ ProgramFiles \\ Internet Explorer \\ iexplore.exe \” http://mydomain.com/admin/index.php?action=central_alertas.php&act=1     
        我建议下载Windows的cURL,因为它可以为您向服务器发出页面请求。然后,您可以使用Windows Task Scheduler执行
curl script.php?task=aaa
。     

要回复问题请先登录注册