使用 PHP 检测远程 SMB 共享上的文件修改
我正在编写一个 PHP 进程,该进程将在 Unix 计算机上运行,该进程需要监视远程 SMB 服务器并检测通过 FTP 上传到该服务器的新文件。我不太可能能够
它需要检测:
- 正在创建的新文件
- 文件上传完成
- 文件正在删除
如果它是 NFS 共享,我会尝试使用 FAM 来检测事件,但我看不到办法做任何同等的事情?
I'm writing a PHP process that will run on a Unix machine that will need to monitor a remote SMB server and detect new files that are being uploaded to that box via FTP. It's unlikely I'll be able to
It will need to detect:
- New files being created
- File upload completing
- Files being deleted
If it was an NFS share, I'd try using FAM to detect the events, but I can't see a way of doing anything equivalent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来不像我会在生产中使用的东西。但您可以尝试这样的操作:
运行 PHP 的机器
守护进程
递归迭代器迭代器与
DirectoryIterator 来收集和
维护所有文件的列表并
共享驱动器上的文件
刷新一下文件夹列表并
与当前状态进行比较,
如果文件不再存在
你知道它已被删除,如果
有一个新文件将其放入
排队并将其标记为“正在
已上传”
检查排队的文件,它是文件
文件上传大小没有改变
可能已完成,如果文件大小
更改后再次将其放入队列中
并将其标记为“正在上传”
Doesn't sound like something I would use in production. But you could try something like this:
the machine that is running a PHP
daemon
RecursiveIteratorIterator with
DirectoryIterator to collect and
maintain a list of all the files and
folders on the shared drive
a while refresh the folder list and
compare it with the current state,
if the file does not exist any more
you know it has been deleted, if
there is a new file put it in the
queue and mark it as "being
uploaded"
check the queued file, it the file
size did not change the file upload
probably completed, if the file size
changed put it in the queue again
and mark it as "being uploaded"