Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am in need of a script or program that can scan an entire drive and output a summary that lists space used by month. A script would be great since I would like to use it on several *nix platforms, and maybe Windows.
I am looking for something that I can go up to a system at "anytime" and get a report of the space use by month. For example I could run this on a "Home Directory" tree and could see what month the users used the most space. Unfortunately I do not have the option of running a script every month to record history.
If you don't record how much space is used monthly I'm not sure how you are going to have something to compare against.
You could get a usage for each directory and subdirectory on the system by running:
find / -type d -exec du -hs {} \;
It will take a while to run though. Obviously it will just search from the base of the find command so you can limit it to a specific area of the system.
Originally posted by tommeke the `cron` system is made for running scripts on regular times or time intervals.
make script, probably something like
#!/bin/bash
df -h
(make it executable), test it
man cron : you'll get it running in no time!
And if you wanted you could have it log to a file to keep the results all in one place, even creating a script to parse the data in the log file to display month by month.. etc...
This is more difficult to explain than I though, but I appreciate the responses so far. First thing is that I don't want a running history of files by month, I want it do count the disk space consumed and sort it by month. For example lets say I have this directory:
-rw-r--r-- 1 mark users 1906 2004-12-29 06:42 file01.txt
-rw-r--r-- 1 mark users 560111 2004-12-06 18:20 file02.txt
-rw-r--r-- 1 mark users 472877 2005-01-09 07:31 file03.txt
-rw-r--r-- 1 mark users 444050 2005-01-09 07:30 file04.txt
-rw-r--r-- 1 mark users 444606 2005-01-09 07:31 file05.txt
-rw-r--r-- 1 mark users 744910 2005-01-06 18:20 file06.txt
-rw-r--r-- 1 mark users 2065188 2005-02-06 18:20 file07.txt
-rw-r--r-- 1 mark users 9049086 2005-02-13 15:33 file08.txt
-rw-r--r-- 1 mark users 229992 2005-02-09 07:30 file09.txt
-rw-r--r-- 1 mark users 364104 2005-03-06 18:20 file10.txt
-rw-r--r-- 1 mark users 809125 2005-03-23 19:08 file11.txt
-rw-r--r-- 1 mark users 463835 2005-03-17 20:49 file12.txt
-rw-r--r-- 1 mark users 214307 2005-04-06 18:20 file13.txt
-rw-r--r-- 1 mark users 498334 2005-04-06 18:20 file14.txt
-rw-r--r-- 1 mark users 6316 2005-04-11 17:37 file15.txt
I want a script/program that would run on a single or nested directories that would count the disk space consumed and then sort it by month. So my ideal output would look like this:
So the 564017 is the total space consumed by files in 12-04 (file01.txt + file02.txt) If I ran this in the future I would not want it to compare any dates or files from before, I just want it to recount the files, and add the sizes up by date. This is a small sample but I could then use this data to say that the most disk space was consumed in 02-05. I think the tricky thing is that I need it to count disk space consumed by month for the entire directory tree that it is ran on, so it would need to add every directory up for a grand total at the end. I hope this helps, please don't give up I know there has to be a way to do this I just lack the time (and know-how) to figure it out.
I am trying to find the diskspace consumed by files older than 30days, 60days, 90days, and 180days, etc. I know that the find command can locate files by age, but since I want multiple ages and sizes I want to avoid running find (4) times. Is there a way to take output from ls and then run it through a script to get this data?
For example:
> ls -la / > output.out
> somescript < output.out
Age Space used
30 231MB
60 601MB
90 1031MB
180 2321MB
This way I only need to scan the entire tree once, and then run my script later or even on a different host.
dirvish looks like a cool project to look into thanks! Also after reading the docs it does not look like it will just report without vaulting (backup) the data.
Thanks!!!! This is a great help!!! I did add the -R to make it recursive but I end up with multiple same month totals. I think it count all the files in a directory on a certain month but when it starts another directory and the month is not the same it totals and then continues. I will then get a 2005-04 for the main directory and the subdirectoies. I have modified the script to read in a sorted ls output, but I haven't figured out a way to do this within the script. Any ideas?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.