简体   繁体   English

php FTP文件:如何检查文件是否被另一个进程打开

[英]php FTP file: How can check if a file is open by another process

I have a list of videos (.mp4) in a remote server. 我有一个远程服务器中的视频(.mp4)列表。 From my application codeigniter, I connect with FTP to the remote server and I can list those videos. 通过我的应用程序代码点火器,我通过FTP连接到远程服务器,并且可以列出这些视频。
I want to rename those files, but I should verify if file is opened by another process (video is playing) before renaming it. 我想重命名这些文件,但是在重命名之前,我应该验证文件是否由另一个进程打开(正在播放视频)。
How can check if a file is opened by another process with php? 如何检查文件是否被php的另一个进程打开?

This my code: 这是我的代码:

$ftp = new Simple_ftp();
$ftp->init("server",'login','password');
$conn_id = $ftp->connexion();
if($conn_id == 3){
    $files = $ftp->ls('path_files');
    foreach($files as $file){
        ...
    }
}

You cannot check for that having only FTP access. 您无法检查是否只有FTP访问权限。

If the server is using Linux based OS and you have ssh access, you can remotely connect and use the lsof program. 如果服务器使用基于Linux的操作系统,并且您具有ssh访问权限,则可以远程连接并使用lsof程序。

There is no way of knowing by FTP, however other methods I suggest taking a look at the following: flock 无法通过FTP进行了解,但是我建议您查看以下其他方法: 羊群

It checks for file locking 它检查文件锁定

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

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