[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: check a file within a certain time



Hi Ron:

En fecha Sábado, 5 de Mayo de 2012, ron ramos escribió:
> Hi All,
> 
> This is more of a general linux question. I would like to test if a
> file if exists, and if the test does not respond in 5 seconds it'
> considered failed.
> 
> reason for this is that i have web servers that has mounted nfs
> volumes, but when the NFS server is high on load accessing the nfs
> mount on the web servers seems slow.

/usr/bin/time -f'%e' [ -e /mnt/mynfs/somefile ]

That will return the "real time" in seconds.

I'm using the absolute path '/usr/bin/time' because time is also a Bash built-
in; you'll need to install the "time" package if not already so.

It might happen that due to caching `[ -e /mnt/mynfs/somefile ]` returns fast 
even if the NFS mount point is clogged, reading a file might be better:

/usr/bin/time -f'%e' cat /mnt/mynfs/somefile > /dev/null

Cheers.


Reply to: