简体   繁体   English

使用cron时ftp_connect()不起作用

[英]ftp_connect() is not working when using cron

This is the line in question, just for testing: 这是有问题的行,仅用于测试:

var_dump(ftp_connect("ftp.something.com"));

The script above works fine if i call it from the browser, the response is the following: 如果我从浏览器中调用上面的脚本,效果很好,响应如下:

resource(1) of type (FTP Buffer)

If i try to call it using cron or from the shell, the response is: 如果我尝试使用cron或从shell调用它,则响应为:

bool(false)

So looks like the ftp_connect function is working fine using cron, but somehow it can't connect to an external location. 因此,看起来ftp_connect函数在使用cron时工作正常,但由于某种原因它无法连接到外部位置。 If i change the ftp address to "localhost", its working fine again: 如果我将ftp地址更改为“ localhost”,则其再次正常工作:

resource(4) of type (FTP Buffer)

Any idea what might cause this issue? 任何想法可能导致此问题? Maybe a firewall on the server? 也许服务器上有防火墙?

Connection to a ftp server across proxy 跨代理连接到ftp服务器

$ftp_server = "proxy"; f.e. 123.456.789.10
$ftp_user_name = "username@ftpserver"; f.e. exampleuk@www.example.uk
$ftp_user_pass = "password";

$conn_id = ftp_connect($ftp_server, 2121);
$login_result = ftp_login( $conn_id, $ftp_user_name, $ftp_user_pass );

The other useful function is set_time_limit(0); 另一个有用的功能是set_time_limit(0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM