连续监视linux中的目录,并在新文件可用时通知
发布时间:2020-12-13 19:38:51 所属栏目:Linux 来源:网络整理
导读:我是 linux和脚本环境的启动器.我的要求是这样的: 1) From an asp.net application,a file will be generated and copied to a predefined folder in a linux server machine. (I'm assuming this can be done by remote file sharing using samba server)2
我是
linux和脚本环境的启动器.我的要求是这样的:
1) From an asp.net application,a file will be generated and copied to a predefined folder in a linux server machine. (I'm assuming this can be done by remote file sharing using samba server) 2) A service or script or whatever should be there in linux machine to track continuously whether file is available. 3) Once a new file is available,just parse the file,extract some input variables and execute a shell script based on these parameters. 我的问题在于第2点. – >如何编写应该连续执行的服务或脚本,并监视某个文件夹中的文件是否可用? 我搜索了很多,有很多链接,我很困惑什么是最简单的方法来做到这一点.因为我不想在这里花费大量的编码作为脚本进一步执行,asp.net应用程序更重要,这应该是之间的连接器. 任何人都可以指导我正确的方式.如果以前有类似的问题,请分享链接,因为我找不到类似的东西. 解决方法
你正在寻找类似于inotify的东西. [cnicutar@ariel ~]$inotifywait -m -e create ~/somedir/ Setting up watches. Watches established. /home/cnicutar/somedir/ CREATE somefile 例如,您可以在循环中执行此操作: inotifywait -m -e create ~/somedir/ | while read line do echo $line done (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |