Posted: Fri Jul 04, 2008 8:10 am Post subject: check an nfs mount in a script
Hi,
Ive been looking for a way to do this but cant figure it out.
I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
Posted: Fri Jul 04, 2008 1:10 pm Post subject: Re: check an nfs mount in a script
On Thu, 03 Jul 2008 19:04:40 -0300, <cconnell_1@lycos.com> wrote:
Quote:
Hi,
Ive been looking for a way to do this but cant figure it out.
I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
Posted: Fri Jul 04, 2008 1:10 pm Post subject: Re: check an nfs mount in a script
On Thu, 03 Jul 2008 17:30:50 -0700, cconnell_1 wrote:
Quote:
On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
Hi,
Ive been looking for a way to do this but cant figure it out.
I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
thanks this worked well. one side effect is after the script it leaves
the df -t commands around and also the script says its running from ps.
is there any way to terminate the df or send a control-c to it after the
timeout?
However, on a hard,nointr mount, maxtime will leave processes behind too,
though they should die as soon as the mount comes back.
To get around that, you'll probably need to change the mount options on
your NFS mount - probably in /etc/fstab, /etc/vfstab, /etc/checklist, or
an automount map. You could probably change it to soft (mount will time
out and disappear after a while) or intr (processes attempting to use the
mount are interruptible even if the NFS mount is timing out).
Posted: Fri Jul 04, 2008 1:10 pm Post subject: Re: check an nfs mount in a script
On Thu, 03 Jul 2008 21:30:50 -0300, <cconnell_1@lycos.com> wrote:
Quote:
On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
Hi,
Ive been looking for a way to do this but cant figure it out.
I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
thanks this worked well. one side effect is after the script it leaves
the df -t commands around and also the script says its running from
ps.
is there any way to terminate the df or send a control-c to it after
the timeout?
If the df survived, this may be a better solution:
Posted: Fri Jul 04, 2008 1:10 pm Post subject: Re: check an nfs mount in a script
On 4 Jul, 00:29, mop2 <inva...@mail.address> wrote:
Quote:
On Thu, 03 Jul 2008 19:04:40 -0300, <cconnel...@lycos.com> wrote:
Hi,
Ive been looking for a way to do this but cant figure it out.
I have a script that checks an nfs mount with this condition (linux
bash) and makes sure its not full:
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
thanks this worked well. one side effect is after the script it leaves
the df -t commands around and also the script says its running from
ps.
is there any way to terminate the df or send a control-c to it after
the timeout?
dirpresent=`df -T | grep -w nfs | grep -w $nfsdir | grep -wv "100%"`
if [ -n "$dirpresent" ]; then
etc etc
fi
My problem is if the nfs server is down, then the df command hangs so
the whole script hangs. Is there a way I can time the reponse so if
say I dont get a response after 5 seconds, then abort the df check?
Decades ago when I had to deal with this (we had 100's of NFS file
servers), I seem to recall it was better to launch a job in the
background, if an NFS job might hang it up.
So it might be better to have a loop run the "df" command in the
background, and in another shell check the output.
I did two other things to reduce the risk of server hanging:
1) Keeping excess directories out of my searchpath
2) creating a directory on the local machine that had symbolic links
to the executables on remote diorectories, and use this directory in
my searchpath instead of the other).
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum