File System Check using shell script !!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File System Check using shell script !!!
# 1  
Old 12-26-2005
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  
Old 12-27-2005
Java 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  
Old 12-27-2005
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  
Old 12-28-2005
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  
Old 01-03-2006
just type the mount commmand without any options or the df command to find out all the mounted filesystems...
# 6  
Old 01-03-2006
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  
Old 01-03-2006
just issuing "mount" or "df" will never harm anything... so dont worry anything about it ...

some of the errors u may get while mounting is :
--filesystem does not have permission (in case of NFS)
--no mount point defined...

....etc .... etc....

in case u dont want the errors to show uo on the screen, then redirect the stderr stream to some file and view the file later
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to check a file

I'm required to write a simple shell script that when it runs it writes the output which is a simple barcode to a tmp flat file which I can do the bit I'm struggling with... The next time it runs I need to check the tmp output file to see if that barcode is in the output file and if it is send... (5 Replies)
Discussion started by: worky
5 Replies

2. UNIX for Dummies Questions & Answers

Need shell script to check file

Hi Experts, I am not good in writing script. Just stared.I am looking for shell script to check following parameters. 1) Number of files on remote Linux SUSE server.- Any directory and sub directory. 2) I should define number of files in script. Files should be variable. 3) Age of... (2 Replies)
Discussion started by: ApmPerfMonitor
2 Replies

3. Shell Programming and Scripting

How to check the duplicancy of file using shell script?

Hi all, i am getting the file through sftp from a location in the name of 20141201_file.txt (iam getting the file on daily basis with date appended at the beginning) so before going to my actual process ,i want to check whether today files and yesterday file are same or not(which i used to... (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Shell Programming and Scripting

Help with a shell script to check /var file system

deleting (0 Replies)
Discussion started by: fretagi
0 Replies

5. Shell Programming and Scripting

How to check file name format using shell script?

Hi, I am writting a script, which accepts input file as parameter. Input file name is aa_bb_cc_dd_ee.<ext> I need to check that input file name should be of 5 fileds. Please help me out. :confused: (7 Replies)
Discussion started by: Poonamol
7 Replies

6. Shell Programming and Scripting

Script to check file system size

Dears, the output of this command df -h | tr -s ' ' | cut -f5 -d' ' is capacity 24% 0% 0% 0% 0% 1% 0% 24% 24% 0% 93% 1% (4 Replies)
Discussion started by: xxmasrawy
4 Replies

7. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

8. Shell Programming and Scripting

Need to check for empty file in C shell script

I am running a C shell script. I have an output file from a previous step and I need to run "something" in the next step to check if the file is empty. If the file is empty, then the job script should finish EOJ. If the file is not empty then the job script should abend. Please help Thanks. (4 Replies)
Discussion started by: jclanc8
4 Replies

9. Shell Programming and Scripting

need to check the file using ftp in a shell script

i need to write a shell script.. connecting to another server using ftp and check whether the file ter.txt is exists there or not. i have written scirpt partially,as i new to Unix. ftp -inv $FTPHOST > $TEMPFILE1 2> $TEMPFILE1 << EOF user $FTPUSER $FTPPW binary prompt ${CD} ls *.txt... (11 Replies)
Discussion started by: KiranKumarKarre
11 Replies

10. Shell Programming and Scripting

Script to Delete temp files and check file system

Hi all, new to the threads as well as Unix/Linux. I need to create a script that will delete any temporary files as well as check the files on the system for errors or corruption. This is what I have so far and I'm sure that I'm missing things or have the wrong commands. I'm not sure where to go... (3 Replies)
Discussion started by: Bwood1377
3 Replies
Login or Register to Ask a Question