Is there any issue about use ftp functions in PHP running over windows task scheduler?

863

I have a code in PHP runing some FTP functions and it works fine when I execute it in a browser, it reads and record the file into my mysql database, updating a table that keeps the date and time of the last run. unfortunately when I try to do that with task scheduler, the only thing that executes is the date/time of the run, it completly ignore the ftp functions. I already tried another task scheduler but got the same result.

$ftp_server = "server IP";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to 
$ftp_server");
$match[1] = "server IP"; 
$match[2] = "login";
$match[3] = "pw";
$match[4] = "";
$match[5] = "/xml/";
if (ftp_login($conn_id, $match[2], $match[3])) { 
    ftp_chdir($conn_id, $match[5]); 
    $contents = ftp_nlist($conn_id, ".");
    foreach( $contents as $i=>$d) {
        $local_file=$d;
        $server_file=$d;
        ftp_get($conn_id, $local_file, $server_file, FTP_ASCII);
    }
}
$now=date('Y-m-d H:i:s');
$conexao=mysqli_connect('localhost','root','','mydb');
$query="update parametros set leitura_xml='$agora' where id=1";
mysqli_query($conexao,$query) or die(error_log('gravacao da data de leitura xml '.mysqli_error($conexao)));

As I said, when running on a browser, it works very well, but when running on task scheduler, only the update to mysql works, which means that the code is runnig, but the ftp codes donĀ“t. Sorry about my english.

People are also looking for solutions to the problem: php - How to perform an action just before submitting a payment in PrestaShop?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.