Sponsored Content
Top Forums Shell Programming and Scripting Disk usage with links pointing to files on same FS Post 302885953 by rbatte1 on Wednesday 29th of January 2014 05:26:41 AM
Old 01-29-2014
When you say "all" directories, do you want to descend the top level directories from your current position and report them too? If so, leave off the -s flag. It may be useful to pipe this into a sort as below:-
Code:
du -kx | sort -n

You can choose if you want to include the -L flag. I think that links to files will just count the link where links to a directory will count the content of the directory. Of course, you are not considering hard links within your filesystem, however in my testing, I have found that if I have:-
Code:
robin @ /tmp/robin>ls -l
total 8
drwxr-xr-x 2 robin robingrp 4096 Jan 29 10:18 1
drwxr-xr-x 2 robin robingrp 4096 Jan 29 10:19 2
lrwxrwxrwx 1 robin robingrp    1 Jan 29 10:19 3 -> 2
robin @ /tmp/robin>ls -li 1 2
1:
total 183340
528470 -rw-r--r-- 2 robin robingrp 187740160 Jan 29 10:18 bigfile

2:
total 183340
528470 -rw-r--r-- 2 robin robingrp 187740160 Jan 29 10:18 bigfile
robin @ /tmp/robin>

..... you can see that directories 1 & 2 contain the same file hard linked (same inode number) and directory 3 is symbolically linked.

I then get this output:-
Code:
robin @ /tmp/robin>du -k
183344  ./2
4       ./1
183352  .
robin @ /tmp/robin>

..... so the file is only reported once. i must admit I don't know why it is reported under directory 2 rather than 1, but it's something to be aware of.
You can also see that 3 doesn't list at all.

This is on RHEL6, but other operating systems may vary. It might be that it reports the space used under 1 as the same as 2, but the total doesn't match up.

I hope that this helps.


Robin
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Pointing one hard drive name to another disk

Pointing one hard drive name to another disk -------------------------------------------------------------------------------- I have 2 disk drives - s2d9 & s2d11 on a solaris Unix system It was mapped so that anything that tried to call s2d9 would be pointed to s2d11 since s2d9 was bad.... (2 Replies)
Discussion started by: andy57s
2 Replies

2. UNIX for Dummies Questions & Answers

disk usage

how to i find out the disk usage on a server. say in windows examples its like C:/ D:/ and checking out the disk space. how can i find in Unix. can i just use df -k or should i go to each volume group and find that way. plz respond (2 Replies)
Discussion started by: karthikosu
2 Replies

3. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

4. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

5. UNIX for Dummies Questions & Answers

How to trace the big files causing high disk usage

Hi All, One very urgent issue and I need your help. I have two V490 servers installed with Sun Solaris 10. I have traced out that the disk usage is running out of space for both the servers. Currently the /dev/md/dsk/d10 device is 91% in one server and another is 56% and it is increasing... (1 Reply)
Discussion started by: ailnilanjan
1 Replies

6. UNIX for Dummies Questions & Answers

du - Disk Usage for only files and NOT directories.

Hello, Could any one help me how to find the Disk Usage for all the files in the running directory and the sub directories without the disk usage of the directory. I mean to say, i need only the file names without the size of the directories. See, i used this command du -a .|sort... (3 Replies)
Discussion started by: RRVARMA
3 Replies

7. Red Hat

Disk usage showing 100% after deleting files also | Red Hat Linux 3.2.2-5

My Redhat Linux system is always showing 100& disk usage. I have removed almost all the files, but no use and I am always getting 100% disk usage.!! Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda2 36337384 36066352 0 100% / I can... (7 Replies)
Discussion started by: sanoop
7 Replies

8. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

9. UNIX for Advanced & Expert Users

Comparing two files and writing mismatched rows along with mismatched columns. Pointing out the mism

I got a requirement where I need to compare two files wrt to each columns and write the corresponding difference in another file along with some identification showing mismatched columns. Pointing out the mismatched columns is my main problem statement. For example we have files like: File 1 ... (8 Replies)
Discussion started by: piyush pankaj
8 Replies

10. UNIX for Beginners Questions & Answers

Disk usage monitoring and record the disk used in last 24 hour

HI I am Trying to edit the below code to send email every day with difference of disk utilized in for last 24 hours but instead getting same usage everyday. can you please help me to point out where my calculation is going wrong. Thank you. ================= #!/bin/bash TODAY="at $(date... (0 Replies)
Discussion started by: Mi4304
0 Replies
SCHED_GET_PRIORITY_MAX(2)				      BSD System Calls Manual					 SCHED_GET_PRIORITY_MAX(2)

NAME
sched_get_priority_max, sched_get_priority_min, sched_rr_get_interval -- get scheduling parameter limits LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sched.h> int sched_get_priority_max(int policy); int sched_get_priority_min(int policy); int sched_rr_get_interval(pid_t pid, struct timespec *interval); DESCRIPTION
The sched_get_priority_max() and sched_get_priority_min() system calls return the appropriate maximum or minimum, respectively, for the scheduling policy specified by policy. The sched_rr_get_interval() system call updates the timespec structure referenced by the interval argument to contain the current execution time limit (i.e., time quantum) for the process specified by pid. If pid is zero, the current exe- cution time limit for the calling process is returned. The value of policy should be one of the scheduling policy values defined in <sched.h>: [SCHED_FIFO] First-in-first-out fixed priority scheduling with no round robin scheduling; [SCHED_OTHER] The standard time sharing scheduler; [SCHED_RR] Round-robin scheduling across same priority processes. RETURN VALUES
If successful, the sched_get_priority_max() and sched_get_priority_min() system calls shall return the appropriate maximum or minimum values, respectively. If unsuccessful, they shall return a value of -1 and set errno to indicate the error. The sched_rr_get_interval() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
On failure errno will be set to the corresponding value: [EINVAL] The value of the policy argument does not represent a defined scheduling policy. [ENOSYS] The sched_get_priority_max(), sched_get_priority_min(), and sched_rr_get_interval() system calls are not supported by the implementation. [ESRCH] No process can be found corresponding to that specified by pid. SEE ALSO
sched_getparam(2), sched_getscheduler(2), sched_setparam(2), sched_setscheduler(2) STANDARDS
The sched_get_priority_max(), sched_get_priority_min(), and sched_rr_get_interval() system calls conform to IEEE Std 1003.1b-1993 (``POSIX.1''). BSD
March 12, 1998 BSD
All times are GMT -4. The time now is 10:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy