Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if sshfs mounted directory is not disconnected?

I have remotely mounted a filesystem using SSHFS to directory /mnt/sshfs.

I need to find out using a shell script if this SSHFS mount is working correctly or if there is a connection reset by peer problem.

If I try to access such an SSHFS filesystem if it is in "disconnected state", the system freezes and waits until it eventually times out.

I want to avoid that. I need to know if SSHFS is working as expected or if there is some connection problem without freezing the system.

like image 996
Frodik Avatar asked Oct 16 '25 03:10

Frodik


1 Answers

I guess just grep the mount command?

if (( $(mount | grep -e 'whatever you like'| wc -l) > 0 ));
then     
echo "mounted"; 
fi
like image 172
monkey Avatar answered Oct 18 '25 23:10

monkey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!