I have a written a shell script that helps me calculate the disk utilization in remote servers using df -h. I'm including the code snippet below
s_arch_1_per=`sshpass -p 'password' ssh root@server_ip_1 "df -h | grep '/Archive_1'| awk '{print $ (NF-1)}'"`
master_per=`sshpass -p 'password' ssh nidhal@server_ip_2 "df -h | grep '/dev/mapper/centos-root'| awk '{print $ (NF-1)}'"`
arch_5_per=`df -h | grep '/archive_1'| awk '{print $ (NF-1)}'`
The problem is either in the local or remote system the execution of df -h sometimes hangs due to corrupt mount points thus preventing my entire shell from executing completely. How do I prevent my script from getting stuck on a line when df -h doesn't work in one of the systems? I want my script to skip a line and continue to the next line if that line is taking too long to get executed.