Welcome to WebmasterWorld Guest from 54.205.20.160

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)

5+ Year Member



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

<?php
$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!'); }

ftp_get($connection,"file1.txt","file1.txt",FTP_ASCII);

ftp_close($connection);
?>

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



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month