Dem*_*Dog 0 linux perl sleep daemon
有类似的问题,但我所追求的是文件存在的实时检测.
我有2个linux盒子/ PC.
[Linux Box 1] - >生成一个名为host的文件(手动执行)
[Linux Box 2] - >有一个守护进程,每2秒休眠一次,检查预期的文件是否存在.如果它存在,它将执行我的ssh命令(当然会显示一个文本显示它被执行了bla bla bla).
PERL SCRIPT:
ctr:
if (-e $file) { system ("ssh $script $host.$display"); }
sleep(2);
goto ctr;
Run Code Online (Sandbox Code Playgroud)
问题 问题是,我似乎无法确定文件是否实时存在,即使它已经存在.
方框1
[machine01:/home/machine01]% /MACHINE/TOOLS/perl/app/host_gen
> executed at 08/21/2015 21:40:32
Run Code Online (Sandbox Code Playgroud)
方框2
Sleeping for 2 seconds [08/21/2015 21:40:22]
Sleeping for 2 seconds [08/21/2015 21:40:24]
Sleeping for 2 seconds [08/21/2015 21:40:26]
Sleeping for 2 seconds [08/21/2015 21:40:28]
Sleeping for 2 seconds [08/21/2015 21:40:30]
Sleeping for 2 seconds [08/21/2015 21:40:32] **<-expected execution**
Sleeping for 2 seconds [08/21/2015 21:40:34]
Sleeping for 2 seconds [08/21/2015 21:40:36]
Sleeping for 2 seconds [08/21/2015 21:40:38]
Sleeping for 2 seconds [08/21/2015 21:40:40]
Sleeping for 2 seconds [08/21/2015 21:40:42]
Sleeping for 2 seconds [08/21/2015 21:40:44]
Sleeping for 2 seconds [08/21/2015 21:40:46]
Sleeping for 2 seconds [08/21/2015 21:40:48]
Sleeping for 2 seconds [08/21/2015 21:40:50]
Sleeping for 2 seconds [08/21/2015 21:40:52]
Sleeping for 2 seconds [08/21/2015 21:40:54]
Sleeping for 2 seconds [08/21/2015 21:40:56]
Sleeping for 2 seconds [08/21/2015 21:40:58]
Sleeping for 2 seconds [08/21/2015 21:41:00]
Sleeping for 2 seconds [08/21/2015 21:41:02]
Sleeping for 2 seconds [08/21/2015 21:41:04]
Sleeping for 2 seconds [08/21/2015 21:41:06]
Sleeping for 2 seconds [08/21/2015 21:41:08]
Sleeping for 2 seconds [08/21/2015 21:41:10]
Sleeping for 2 seconds [08/21/2015 21:41:12] <- It was executed here
TYPE_AND_DISPLAY [wkss machine01.ult.ultera.omps.com:0]
TYPE [wkss] DISPLAY [machine01.ult.ultera.omps.com:0]
Run Code Online (Sandbox Code Playgroud)
检测现有文件几乎需要一分钟或有时10秒.
这很奇怪.
你们有任何想法我怎么能实现我的目标?
提前致谢.
小智 8
之前的serverfault.com问题:如何判断文件是否在Perl的远程文件系统上?
引用该线程;
默认情况下,大多数NFS客户端缓存目录信息60秒.
该线程中提到的解决方案:
使用noac选项在客户端上挂载NFS共享以禁用属性缓存,或使用acdirmin = 0,acdirmax = 0来禁用目录缓存.
| 归档时间: |
|
| 查看次数: |
70 次 |
| 最近记录: |