Solved

checking available room on remote machine

Posted on 2006-11-06
5
207 Views
Last Modified: 2010-04-20

Hello group,

In a bash script, what is the best way of calculating a directory path such /aDir/Backups/.

What I mean is I need to know finding out the available room under this directory.

Thanks,
ak

0
Comment
Question by:akohan
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Luxana earned 250 total points
ID: 17886698
Hi


one way can be:

cd /aDir/Backups

df -h .

to see disk usage by directories in /aDir/Backups you can do

du -sh /aDir/Backups


lubo
0
 

Author Comment

by:akohan
ID: 17886966


thank you I have still a question. What you said works but why when I run:

$ df  

comparing to

$ df /usr/local

I get same number as available room? I thought that they should be different since every directory has assigned a percentage of the while size of hard drive.

Any comment?


0
 
LVL 10

Expert Comment

by:Luxana
ID: 17887043
Any comment?

1) df takes percentage(used memory)
EXAMPLE:

myfolder is in /var/myfolder and my partition /hda3 is mounted to /var
I get different results when I do df -h / and df -h /var

if you type just df -h you should see all partitons you have. In my case it is:
REAL EXMAPLE: :-)

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2             897M  117M  733M  14% /
tmpfs                 253M     0  253M   0% /dev/shm
/dev/hda8              19G   49M   18G   1% /home
/dev/hda3              14G  175M   13G   2% /tmp
/dev/hda6             3.7G  360M  3.2G  11% /usr
/dev/hda7             1.8G   11M  1.7G   1% /usr/local
/dev/hda5              14G  535M   13G   4% /var
/dev/md0               74G  8.5G   62G  13% /srv

df -h /var/www/
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda5              14G  535M   13G   4% /var


2) why grade B if that worked?


lubo
0
 

Author Comment

by:akohan
ID: 17887966

So there is no way to get how much space is left under a specific directory such /usr/local ?

Sorry about B since I got the results but no details I found then. No worries next time I will make it up.
I'm a newbie so lot of question will be here.
0
 
LVL 10

Expert Comment

by:Luxana
ID: 17893249
>So there is no way to get how much space is left under a specific directory such /usr/local ?

well there is but only if you have mounted whole partition to /usr/local !!!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

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