?
Solved

Check samba connection

Posted on 2007-12-05
5
Medium Priority
?
1,126 Views
Last Modified: 2013-12-16
Dear Experts,
I would like to write a script that checks if there is a connection and directory is really mounted (sometimes an entry it appears in /etc/mtab, but there is no connection in fact) This scripts will periodically (using cron) check if the mounted directory is still available.

I am mounting directory suing command (as root)

su - oracle -c "smbmount //192.168.3.1/BITEX_b /home/oracle/BITEX-backup -o username=oracle,password=oracle,rw"

What command should I use to check if SAMBA connection is still available?

Thanks for help

Groxy
0
Comment
Question by:adamgasior
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20418114
Hi,

Why don't you just create / delete a file in that mounted dir  and see if it succeeds or fails.

0
 
LVL 19

Accepted Solution

by:
alextoft earned 160 total points
ID: 20418599
Something quick and dirty like this perhaps?

#!/bin/bash
FILE="/home/oracle/BITEX-backup/a-file-on-your-remote-server
  if [ -f $FILE ];
    then
      echo Samba mount OK
    else
      umount -f /home/oracle/BITEX-backup
      su - oracle -c "smbmount //192.168.3.1/BITEX_b /home/oracle/BITEX-backup -o username=oracle,password=oracle,rw"
  fi


0
 
LVL 19

Expert Comment

by:alextoft
ID: 20418602
Hmm, it appears to have stripped the quotes round the echo statement when I posted, but you get what I mean...
0
 

Author Comment

by:adamgasior
ID: 20441415
it is not really working. When I physically disconnect machines, the touch command hangs
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20441538
OK,

You may monitor the touch command while it is running in the the background

e.g.

touch /sambadir/file &
sleep 3
count=`ps -ef | grep -v grep | grep touch | wc -l`
if test $count -gt 0
then
      echo "not mounted"
      kill -9 `ps -ef | grep -v grep | grep touch | awk '{print $2}'`
else
      echo "mounted"
fi
0

Featured Post

Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question