Operating System - HP-UX
1830862 Members
2620 Online
110017 Solutions
New Discussion

Re: How to tell if nfs mount will fail

 
Theresa Patrie
Regular Advisor

How to tell if nfs mount will fail

Hi,
Is there any way to tell if an nfs mount will fail before you actually try to do it?? I have a script that runs in cron every 15 minutes and writes to a nfs-mounted directory. When nfs is broken, the script hangs. What can I put in the script to check if the needed nfs mount will work before trying to write to it?? Any ideas would be greatly appreciated!
Thanks,
Theresa
This is my easy job!
5 REPLIES 5
Marco Santerre
Honored Contributor

Re: How to tell if nfs mount will fail

Other than trying to ping the host where the local mount point is, I don't have any other ideas of what tests you could do prior to actually going into it.
Cooperation is doing with a smile what you have to do anyhow.
Pete Randall
Outstanding Contributor

Re: How to tell if nfs mount will fail

Theresa,

I'm not sure that this would work and I don't have a broken NFS mount to try it on, but maybe you could try doing an "ls -l" on the directory and check it with "wc -l". If you don't get any lines back, then you're mount is probably broken.


Pete

Pete
RAC_1
Honored Contributor

Re: How to tell if nfs mount will fail

Before you mount NFS directory, you can check if it accessable to you.

(Just ping will do)

Also you can use showmount to see if filesystem you want to mount is exported from server or not.

Further you can check ping response to see the network quality.
There is no substitute to HARDWORK
Mark Grant
Honored Contributor

Re: How to tell if nfs mount will fail

You can't really but you could make your script time out by getting it to run a "sleep 30 && kill $$" in the background and killing $# if your file read is successful.

This basically translates to...

start a process in the background that will kill my script after 30 seconds. However, if my script works then kill the process that was about to kill me.

Crude but cute.
Never preceed any demonstration with anything more predictive than "watch this"
Theresa Patrie
Regular Advisor

Re: How to tell if nfs mount will fail

I don't think ping is the way to go because mounts can fail for other reasons even if ping shows the machine is alive. "ls -l" will not work because that acutally also causes a hang if nfs is broken. I like the creative approach, Mark. I'll have to come up with a little script and check it out. From the responses so far, looks like a creative workaround is the only way to go...
Thanks!
This is my easy job!