Hang NFS shell script check


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Hang NFS shell script check
# 1  
Old 04-10-2014
Hang NFS shell script check

Hello all,

i wrote a shell script that was running perfectly fine until we had some issue with our NFS server and the script was hung.
This script runs every 20 mins and obviously as we had the NFS issue, the script start to hang. as i do a check to make sure
NFS directory is avaiable or not. Original check i had in place was below, now i am trying to modify so i can run this even
when NFS is done or atleast the script does not hang

Code:
  if [ -d /nfs/stage ]; then
    echo "NFS is avaiable,go to next steps"
  else
    echo "NFS is NOT avaiable"
    echo "NFS NOT Available |mailx -s "Backup failed ..." email@domain.com
    exit 1
  fi

with new modification....
Code:
   if [ `ls /nfs/stage|wc -l` -gt 0 & sleep 5; kill $! ]; then
    echo "NFS is avaiable"
  else
    echo "NFS is NOT avaiable"
  fi


But that does not seem to work. i was thinking to use the timeout command but i have to make this script work on linux and hp-ux and
i believe hp-ux dose not have the timeout command.

Any thoughts on how i can do a check without haning my script?

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 04-10-2014 at 12:39 PM.. Reason: code tags + typos
# 2  
Old 04-10-2014
Quote:
linux and hp-ux
which are server which are clients?
NFS can be very tricky on HP-UX... and so needs some tuning because some software (e.g. "non intrusive" secusrity scans can get you NFS server to almost freeze...)
# 3  
Old 04-10-2014
clients are hp-ux and linux and same goes for server too(some NFS server are on HP-UX and some one linux)....

so thats why i need a script that work on both linux and HP-UX....
# 4  
Old 04-10-2014
Ever considered using touch rather than ls?
# 5  
Old 04-10-2014
any specific reason why touch is better than ls ? in this case
# 6  
Old 04-10-2014
Code:
df /nfs/stage >/dev/null 2>&1 </dev/null &
sleep 5
if kill -0 $! 2>/dev/null
then
  echo "NFS is not available"
  kill -9 $!
  exit 1
fi
...

# 7  
Old 04-10-2014
Is there a way to do the same thing without the KILL command?

as i do not have access to that....would something like below work??
Code:
df /oracle/stage >/dev/null 2>&1 </dev/null &
sleep 5
STATUS=`ps -ef|grep $$|wc -l`
if [ $STATUS -ge 1 ]; then
echo "alive"
else
echo "not alive"
fi


Last edited by Franklin52; 04-11-2014 at 03:36 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX 5.3 NFS export not mounting, rpcinfo hang/timeout on server

Been trying to get a directory NFS-mounted with no success. I've tried both NFS v3 and v4, but currently trying v4. I can't figure out what's going on here. server: sbkovwadmd01 sbkovwadmd01# chnfsdom Current local domain: edw.dev sbkovwadmd01# lssrc -a | grep nfs | grep active nfsd ... (3 Replies)
Discussion started by: eckertd
3 Replies

2. Shell Programming and Scripting

Mount NFS Share On NFS Client via bash script.

I need a help of good people with effective bash script to mount nfs shared, By the way I did the searches, since i haven't found that someone wrote a script like this in the past, I'm sure it will serve more people. The scenario as follow: An NFS Client with Daily CRON , running bash script... (4 Replies)
Discussion started by: Brian.t
4 Replies

3. How to Post in the The UNIX and Linux Forums

NFS mounted and unmounted shell script

Hi, I making a script to check nfs mount and unmount options. After various findings, i didn't get any solution for that. Can you please help me in making the script. 1) I have used, if grep -qs '/var/JETSHARE' /proc/mounts; then echo "It's mounted." else echo "It's not mounted. ... (2 Replies)
Discussion started by: Santosh101
2 Replies

4. HP-UX

HPUX 11.11 NFS client hang

Hi. I'm having problems with my HP C8000 and 11.11 (ifs client needs to be restarted every week), trying to get it worked out. When I searched the web it seems, I require the following patches: PHKL_41041, PHKL_43823, PHKL_43577 Is there anyway to get hold of these packages? Many thanks... (2 Replies)
Discussion started by: plantage
2 Replies

5. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

6. Solaris

Df -h hang cant see any NFS storage

Hi all I had a server, when run the df -h command, it hang, and need to press "crtl+c" to terminate it. i cant other NFS filesystem anymore. but i try at other server, the NFS filesystem is work properly any idea on this? # mount -p /dev/md/dsk/d0 - / ufs - no... (1 Reply)
Discussion started by: SmartAntz
1 Replies

7. Shell Programming and Scripting

Why Does this Shell Script Hang?

I have this short and simple shell script that processes a log file with the following format: and attempts to generate output in the following format: I've come up with the following, but for some reason, it only prints output correctly for the first line of the input file,... (8 Replies)
Discussion started by: Zoetermeer
8 Replies

8. UNIX for Dummies Questions & Answers

NFS client subsystem hang up on boot

Hi, I have a Unix box running HP-UX 10.20 and it suddenly won't boot. Every time it goes down the boot checklist, it hangs on "NFS client subsystem" and just continues to say busy/wait. I have read something about the /etc/auto_master but don't quite understand what has to happen to fix it. ... (4 Replies)
Discussion started by: Asheley Ryan
4 Replies

9. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

10. UNIX for Dummies Questions & Answers

sudo logging + NFS hang?

Hi all, I have two problems, My system is SunOS 5.9: 1- I have installed sudo but I have a problem logging user activities on other hosts, the way I installed it is that I installed sudo and the sudoers file in a shared directory on a NFS server which is mounted by all computers on the... (1 Reply)
Discussion started by: neked
1 Replies
Login or Register to Ask a Question