分享

写回答

发帖

[提问] godaddy Cron Job设置不起作用

GoDaddy GoDaddy 972 人阅读 | 9 人回复

发表于 2011-6-1 17:16:03 | 显示全部楼层 |阅读模式

godaddy Cron Job设置不起作用,本想用这个功能执行一个PHP页面。但是设置了时间段选好了路径,一整天过去了。也没有执行过这个PHP页面。请高手赐教!

回答|共 9 个

lwbo1987

发表于 2011-6-1 17:40:32 | 显示全部楼层

是不是代码写的不正确
回复 支持 反对

使用道具 举报

sztxkj

发表于 2011-6-1 18:15:34 | 显示全部楼层

指定的文件是:crontab.php
以下是crontab.php
的代码
  1. <?php

  2.   sockOpenUrl("http://www.xxxx.com/newlist.php");

  3.   

  4.   function sockOpenUrl($url,$method='GET',$postValue=''){



  5.         $method = strtoupper($method);



  6.         if(!$url){



  7.                 return '';



  8.         }elseif(!ereg("://",$url)){



  9.                 $url="http://$url";



  10.         }



  11.         $urldb=parse_url($url);



  12.         $port=$urldb[port]?$urldb[port]:80;



  13.         $host=$urldb[host];



  14.         $query='?'.$urldb[query];



  15.         $path=$urldb[path]?$urldb[path]:'/';



  16.         $method=$method=='GET'?"GET":'POST';







  17.         $fp = fsockopen($host, 80, $errno, $errstr, 30);



  18.         if(!$fp)



  19.         {



  20.                 echo "$errstr ($errno)
  21. \n";



  22.         }



  23.         else



  24.         {



  25.                 $out = "$method $path$query HTTP/1.1\r\n";



  26.                 $out .= "Host: $host\r\n";



  27.                 $out .= "Cookie: c=1;c2=2\r\n";



  28.                 $out .= "Referer: $url\r\n";



  29.                 $out .= "Accept: */*\r\n";



  30.                 $out .= "Connection: Close\r\n";



  31.                 if ( $method == "POST" ) {



  32.                         $out .= "Content-Type: application/x-www-form-urlencoded\r\n";



  33.                         $length = strlen($postValue);



  34.                         $out .= "Content-Length: $length\r\n";



  35.                         $out .= "\r\n";



  36.                         $out .= $postValue;



  37.                 }else{



  38.                         $out .= "\r\n";



  39.                 }



  40.                 fwrite($fp, $out);



  41.                 while (!feof($fp)) {



  42.                         $file.= fgets($fp, 256);



  43.                 }



  44.                 fclose($fp);



  45.                 if(!$file){



  46.                         return '';



  47.                 }



  48.                 $ck=0;



  49.                 $string='';



  50.                 $detail=explode("\r\n",$file);



  51.                 foreach( $detail AS $key=>$value){



  52.                         if($value==''){



  53.                                 $ck++;



  54.                                 if($ck==1){



  55.                                         continue;



  56.                                 }



  57.                         }



  58.                         if($ck){



  59.                                 $stringdb[]=$value;



  60.                         }



  61.                 }



  62.                 $string=implode("\r\n",$stringdb);



  63.                 //$string=preg_replace("/([\d]+)(.*)0/is","\\2",$string);



  64.                 return $string;



  65.         }



  66. }

  67.   

  68. ?>
复制代码
回复 支持 反对

使用道具 举报

sztxkj

发表于 2011-6-1 18:27:56 | 显示全部楼层

顶起来。在线等。
回复 支持 反对

使用道具 举报

cryz

发表于 2011-6-1 19:07:03 | 显示全部楼层

直接访问可以执行吗?
回复 支持 反对

使用道具 举报

sztxkj

发表于 2011-6-1 19:16:18 | 显示全部楼层

肯定可以执行
回复 支持 反对

使用道具 举报

cryz

发表于 2011-6-1 19:19:10 | 显示全部楼层

贴一下设置看看
回复 支持 反对

使用道具 举报

sztxkj

发表于 2011-6-1 19:22:50 | 显示全部楼层

哈哈哈。解决了!
回复 支持 反对

使用道具 举报

ybbao

发表于 2011-6-1 20:22:44 | 显示全部楼层

需要在前面加php路径

/web/cgi-bin/php5 "路径/crontab.php"
回复 支持 反对

使用道具 举报

lwbo1987

发表于 2011-6-2 09:29:22 | 显示全部楼层

回复 8# 的帖子

如何解决,分享下,谢谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则