监视目录以获取没有第三方包的更改
Many other questions is about this around StackOverflow. I haven't found any where the result doesn't use any 3rd party package.
围绕StackOverflow还有很多其他问题。我没有找到任何结果不使用任何第三方包的地方。
The problem is that I'm using Hetzner and they want allow me to install any packages.
问题是我正在使用Hetzner,他们希望允许我安装任何软件包。
I can use PHP, Python, Java (think pretty much the standard collection)
我可以使用PHP,Python,Java(几乎认为是标准集合)
How to monitor a directory (recursive) for new files and get the references into another file.
如何监视新文件的目录(递归)并将引用引入另一个文件。
I have tried something like this:
我尝试过这样的事情:
while true; do
last=`cat log.txt`
find "$UPLOAD_FOLDER"'/.' -type f > 'log.txt'
now=`cat log.txt`
diff -n <(echo "$last") <(echo "$now") >> 'queue.txt'
sleep 60;
done;
But it's unreliable and it pollutes queue.txt
with d3a
,b5a
, etc..
但它不可靠,它用d3a,b5a等污染queue.txt。
2 个解决方案
#1
1
Probably the easiest is to use a marker file:
可能最简单的方法是使用标记文件:
touch markerFile
while true
do
find "$UPLOAD_FOLDER"'/.' -type f -newer markerFile >> 'queue.txt'
touch markerFile
sleep 60
done
Might be a slight race condition between the find and the touch?
在发现和触摸之间可能会出现轻微的竞争条件?
A more complicated double buffering solution as suggested in the comments:
一个更复杂的双缓冲解决方案,如评论中所示:
touch markerFileA
touch markerFileB
while true
do
touch markerFileB
find "$UPLOAD_FOLDER"'/.' -type f -newer markerFileA ! -newer markerFileB >> 'queue.txt'
sleep 60
touch markerFileA
find "$UPLOAD_FOLDER"'/.' -type f -newer markerFileB ! -newer markerFileA >> 'queue.txt'
sleep 60
done
更多相关文章
- Media-S 简介(一个开源的DRM解决方案)
- AppScan安全问题解决方案
- PLSQL乱码解决方案
- sqlserver 存储过程 递归查询分组+hierarchyid重建会员关系
- 数据库不支持中文解决方案(mysql)
- Mysql替代解决方案Cassandra
- SQL Server 2005递归查询在数据中有循环,这是可能的吗?
- [置顶] Android屏幕适配解决方案
- 物流货运移动APP解决方案