普通网友 2013-08-16 20:46
浏览 23

在命令行上定时

I had previously asked a question, and got the answer, but I think I've run into another problem.

The php script I'm using does this:

1 - transfers a file to my server from my backup server

2 - when it's done transfering it sends some post data to it using curl, which creates a zip file

3 - when it's done, the result is echoed and depending on what the result is; transfers the file, or does nothing.

My problem is this: When the file is small enough (under 500MB) it creates it, and transfers back no problem. When it's larger, it timesout, finishes creating the zip on the remote server, but because it timed out it doesn't get transfered.

I'm running this from a command line on the backup server. I have this in the php script:

set_time_limit(0);                   // ignore php timeout
ignore_user_abort(true);             // keep on going even if user pulls the plug*
while(ob_get_level())ob_end_clean(); // remove output buffers

But it still timesout when I run sudo php backup.php

Is using curl making it timeout like a browser on the other end where the zip is being made? I think the problem is the response isn't being echo'd out.

Edits: (@symcbean) I'm not seeing anything, which is why I'm struggling. When I run it from the browser, I see the loading thing in the address bar. After about 30 seconds it just stops. When I do it from the command line, same deal. 30 seconds and it just stops. This only happens when large zips need to be created.

It's being invoked via a file. The file loads a class, sends the connection information to the class. Which contacts the server to make the zip, transfers the zip back, does some stuff to it then transfers it to S3 for archiving.

It logs into the remote server, uploads a file with curl. upon a valid response, it curls again with the location of the file as a url (I'll always know what it is), which fires up the php file I just transfered over. The zip ALWAYS gets created no problem, even up to 22GB, just sometimes takes a long time of course. After that it waits for a response of "created". Waiting for that response is where it dies.

So the zip always gets created, but the waiting time is what "I think" is making it die.

Second Edit: I tried this from the command line:

$ftp_connect= ftp_connect('domain.com');
$ftp_login = ftp_login($ftp_connect,'user','pass'); 
ftp_pasv($ftp_connect, true);

$upload = ftp_put($ftp_connect, 'filelist.php', 'filelist.php', FTP_ASCII);

$get_remote = 'filelist.php';
$post_data = array (  
    'last_bu' => '0'
);      

$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL, 'domain.com/'.$get_remote);    
curl_setopt($ch, CURLOPT_HEADER, 0 );   
// adding the post variables to the request   
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);   
//echo the following to get response 
$response = curl_exec($ch);     
curl_close($ch);    
echo $response; 

and got this:

<HTML>
<HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator to inform of the time the error occurred
and of anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>
Web Server at domain.com
</ADDRESS>
</BODY>
</HTML>

Again, the error log is blank, the zip still gets created, but because of the timeout around 650MB of creation I can't get the response.

  • 写回答

2条回答 默认 最新

  • dpx49470 2013-08-16 22:01
    关注

    The problem is in the server code that generates the file to be returned.

    Check the php error log

    It may be timing out for a few reasons but the log shouldl tell you why.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器