The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to check solaris system performance jayaramanit Shell Programming and Scripting 3 06-06-2008 04:28 AM
fsck! How to run Full File System Check hungevntelecom HP-UX 3 09-12-2007 04:30 PM
Have a shell script check for a file to exist before processing another file heprox Shell Programming and Scripting 3 11-14-2006 03:26 AM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 02:46 PM
File System Check (fsck) mawalton UNIX for Dummies Questions & Answers 1 09-17-2004 03:54 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-26-2005
csaha's Avatar
csaha csaha is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 81
Question File System Check using shell script !!!

Hi Guys

I m posing this new thread as I didnt get satisfactory result after running search here.

My requirement is very simple (using shell script)

I need to findout what all file systems are mounted -> Then I need check the health of that file system - by disk usage & by doing a simple "touch" on that file system whether I am able to read+write on that file system or not.

Thanks a lot to all in advance
Chirantan
  #2 (permalink)  
Old 12-27-2005
csaha's Avatar
csaha csaha is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 81
Post File System Check using shell script !!!

Hi All

After some research, I have developed this script ... Guys - Pls let me know how doest this sounds like?

cat /etc/fstab | awk '{ print $2 }' | grep -v swap > /tmp/fs-list

for i in `cat /tmp/fs-list`
do
echo " =================== Printing File System $i ===================== "
ls -ltr $i
done

rm /tmp/fs-list

Thanks a lot
  #3 (permalink)  
Old 12-27-2005
ml0fl1n ml0fl1n is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 4
Even if the filesystem isn't mounted your check of it (ls -ltr) will succeed. In other words, the mount *point* probably exists regardless of whether the filesystem is mounted or not.

If you want to find out whether all the filesystems in fstab are mounted, compare the output of df with the filesystems in fstab.

Depending on which OS you are using you can use a 'readonly' fsck to check the filesystem itself.
  #4 (permalink)  
Old 12-28-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Generally you can find what filesystems are mounted on what mount-point on your system by going through the /etc/mnttab file. The format for the file differs between systems, so go through the man page of your mnttab file to get the exact format. Once you get this list, you can do your tests (disk usage, touch, etc.)

One point to note is that you can mount a filesystem without making an entry in the /etc/mnttab file. But I dont think that those will be that common.

One question though, why cann't you use the df or similar command to find the mounted filesystems on your system?
  #5 (permalink)  
Old 01-03-2006
alpha(*)test alpha(*)test is offline
Registered User
  
 

Join Date: Jan 2006
Location: india
Posts: 29
just type the mount commmand without any options or the df command to find out all the mounted filesystems...
  #6 (permalink)  
Old 01-03-2006
csaha's Avatar
csaha csaha is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 81
Quote:

just type the mount commmand without any options or the df command to find out all the mounted filesystems...
I hope mount command is not going to harm anything even if all the file systems are properly mounted ... Pls clarify

And if some how I get some errors while mounting any file system then what kind of messages I should look for ( need to incorporate in the script ) so that at the time of problem it can grep for that kind of errors ....

Thanks a lot
Chirantan
  #7 (permalink)  
Old 03-17-2009
tushargohil tushargohil is offline
Registered User
  
 

Join Date: Mar 2009
Location: India
Posts: 1
Quote:
Originally Posted by csaha View Post
Hi Guys

I m posing this new thread as I didnt get satisfactory result after running search here.

My requirement is very simple (using shell script)

I need to findout what all file systems are mounted -> Then I need check the health of that file system - by disk usage & by doing a simple "touch" on that file system whether I am able to read+write on that file system or not.

Thanks a lot to all in advance
Chirantan
COUNT=`df -k | grep /mnt | wc -l`

#Change your mountpoint according to your requirement

if [ $COUNT = 0 ]; then
date >> /var/log/messages
echo NFS MOUNTS ARE dead
echo NFS is dead >> /var/log/messages
echo Remounting Mounts
sleep 2
/bin/mount -a
sleep 1
else
echo NFS MOUNTS are fine
echo nothing >> /dev/null
fi

Note:- Mount -a read /etc/fstab so make sure you have proper entry for the same.

Cheers!!!
Tushar

Last edited by vbe; 03-17-2009 at 11:49 AM.. Reason: rules conformance (rm URL)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0