2012-05-16 29 views
0

我打算每10秒運行一次cron作業來連接和複製文件,然後刪除。 我不會cron在拷貝文件等時運行,最好的辦法是什麼?限制已經用ftp連接的用戶在php

我可以限制已經連接的用戶嗎?

try { 
    $con = ftp_connect($server); 
    if (false === $con) { 
     throw new Exception('Unable to connect'); 
    } 

    $loggedIn = ftp_login($con, $username, $password); 
    if (true === $loggedIn) { 
     echo 'Success!'; 
    } else { 
     throw new Exception('Unable to log in'); 
    } 

    print_r(ftp_nlist($con, ".")); 
    ftp_close($con); 
} catch (Exception $e) { 
    echo "Failure: " . $e->getMessage(); 
} 

回答

1
if a certain file doesnt exist 
    make the file 
    do stuff 
    delete file 
else if the file exists, but its very old 
    recreate the file 
    do stuff 
    delete file 
else 
    its busy 

如果FTP軟件本身可以限制這個,我不會感到驚訝。可能想檢查。