Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP ftp does not work with Cron

6:04 pm on Nov 16, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2006
posts: 64
votes: 0

I have simple php script that does a FTP between 2 servers.

$server = "ftp.server.com";
$ftp_user_name = "user123";
$ftp_user_pass = "pass123";
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);

if (!$connection || !$login) { die('Connection attempt failed!'); }



When i run this script directly from the browser (http://www.mysite.com/script.php), the file tranfers without any problem. The file copies from server.com to mysite.com.

But when i try to run it from Cron, nothing happens. The file does not transfer and nor does it show any error. I have all other scripts running fine with cron. The cron command is :

/usr/local/bin/php /hsphere/local/home/user/mysite.com/script.php

Please help
8:23 pm on Nov 25, 2010 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 2

It could be the CLI versus CGI executable of PHP. See Command Line Usage in the PHP online manual: [php.net...]
Try running the crontab from /usr/bin/php instead.