space hog


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers space hog
# 1  
Old 01-27-2005
space hog

How can I find the hog AND list files edited in the past day?

I have used du -ks *|sort -nr|pg --to find hog listed in kilobytes

I know find ./ -mtime +1 -- will find files modified in the past day.


How can I combine them or what would be a better way?

The reason for this is that I had a dir getting full and within that directory it was pretty even accross 10 directories as to the highest Mb amount. Wanted to narrow down where to look for any log files or the culprit that most recently grew too large.


-Thanks
# 2  
Old 01-27-2005
# 3  
Old 01-27-2005
Thanks for the link but I still am having the problem......not able to find the hog AND list files edited in the past day?
# 4  
Old 01-27-2005
I'm still not totally sure how you want the formatting of the final report.

Also, you need -mtime -1 in order to show files modified in the last 24 hours (i.e. a day ago or less).

A basic idea would be something like....
Code:
#!/bin/sh

du -ks * | sort -nr | while read size hog
do
   # Display size of dir/file
   echo "Current Hog - $hog ($size):"
   # Show listing of files modified a day ago or less
   find $hog -mtime -1 -exec ls -l {} \;
done

Although the formatting in the output will need tweaking to your requirements.

Cheers
ZB
# 5  
Old 01-27-2005
Can u explain:

find $hog -mtime -1 -exec ls -l {} \;

I transfered a large file just before executing script so it could be considered a growing hog within 1 day as a test (Al.v1.4.3.410.Retail.rar)
Here is my output:

$ du -ks *|sort -nr|pg
217208 bac.tar
130664 16.1.0.30.tar
86583 ciagent_sms
3280 Al.v1.4.3.410.Retail.rar
3 test
2 house
1 test2.txt.gz
1 test2.txt
1 test1.txt
1 test.sh
1 test.csv
1 script.sh
1 private
1 one
1 hog1
1 hog.sh
1 files.tar.Z
1 dir_link
1 dead.letter
1 date.txt
1 csv_link
0 perm
$
$

HERE IT YOUR SCRIPT:

$ hog.sh
Current Hog - bac.tar (217208):
Current Hog - 16.1.0.30.tar (130664):
Current Hog - ciagent_sms (86583):
Current Hog - Al.v1.4.3.410.Retail.rar (3280):
-rw-r--r-- 1 joek staff 3344362 Jan 27 15:34 Alcohol.120%.v1.4.3.410.Retail.rar
Current Hog - test (3):
Current Hog - house (2):
Current Hog - test2.txt.gz (1):
Current Hog - test2.txt (1):
Current Hog - test1.txt (1):
Current Hog - test.sh (1):
Current Hog - test.csv (1):
Current Hog - script.sh (1):
Current Hog - private (1):
Current Hog - one (1):
Current Hog - hog1 (1):
-rw-r--r-- 1 joek staff 234 Jan 27 15:25 hog1
Current Hog - hog.sh (1):
-rwxrwxrwx 1 joek staff 224 Jan 27 15:48 hog.sh
Current Hog - files.tar.Z (1):
Current Hog - dir_link (1):
Current Hog - dead.letter (1):
-rw------- 1 joek staff 301 Jan 27 11:13 dead.letter
Current Hog - date.txt (1):
Current Hog - csv_link (1):
Current Hog - perm (0):

It looks like it works, but I would like to understand how? How does the last line work? (find $hog -mtime -1 -exec ls -l {} \Smilie

Also, when it searches for the hog for the past day could I format the output using - awk '{print $5,$NF,$6}' so it only displays column 5,6 and the last column of the "ls -l" command (size,filename, date).

I tried to insert that instead of the -exec comand with no luck.


-Thanks
# 6  
Old 01-27-2005
I did some thing like this ...


Code:
find $hog -mtime -1 | xargs ls -l | xargs | tr -s " " | awk ' { print $5,$NF,$6 } '

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies

2. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

3. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

4. Fedora

Need to incrwase PHYSICAL VOLUME space on hard drive with free space on it

Hi, I run Fedora 17. I created a physical volume of 30GB on a disk with 60GB of space so there is 30GB of free space. On the physical volume, I created my volume group and logical volumes. I assigned all the space in the physical volume to my volume group. I need to add the 30GB of free space... (1 Reply)
Discussion started by: mojoman
1 Replies

5. Solaris

No space left on device but free space and inodes are available...

hi guys, me again ;) i recently opened a thread about physical to zone migration. My zone is mounted over a "bigger" LUN (500GB) and step is now to move the old files, from the physical server, to my zone. We are talking about 22mio of files. i used rsync to do that and every time at... (8 Replies)
Discussion started by: beta17
8 Replies

6. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

7. UNIX for Advanced & Expert Users

wake up user space thread from kernel space ISR

Hello, I'm searching for a proper way to let the kernel space ISR(implemented in a kernel module) wake up a user space thread on a hardware interrupt. Except for sending a real-time signal, is it possible to use a semaphore? I've searched it on google, but it seems impossible to share a... (0 Replies)
Discussion started by: aaronwong
0 Replies

8. Solaris

Disk hog utility

Hi, I am looking for an utility on the lines of XDU - A Disk Usage (DU) or other tree display program or xdiskusage for finding disk hogs on a Solaris system. Any clues? Thanks, enc. (2 Replies)
Discussion started by: encrypted
2 Replies
Login or Register to Ask a Question