Sponsored Content
Top Forums Shell Programming and Scripting Age of file in storage / disk Post 302506514 by sheikh76 on Monday 21st of March 2011 04:26:41 AM
Old 03-21-2011
Age of file in storage / disk

Hello all,

Below is scripts to find the file following by:

30 days <- How many total file space within 30 days and not quantity
90 days
120 days
1 year

From here also I can get data space to put on PIE Chart. Following this scripts can I do some enhance from this scripts like do single command then can get total data follow 30 days, 90 days, 120 days and 1 year.

What I'm trying to to is:
1. Get file like "ls -lR | egrep ^-" > test.txt
2. From test.txt get all category 30day, 60day, 90day and 1 year.
3. Value of date convert to percentage.
4. Save as *.csv

Sample for .CSV:
Code:
 
30 days, 20
60 days,30
90 days,40
365 days,80

Scripts A - Get data by day
Code:
 
#!/bin/sh
find /mnt/emage -type f -mtime -30 ! -mtime -0 -exec ls -la {} \; > 30days.txt
cat 30days.txt | awk '{ SUM += $5} END { print "30days " SUM }' >> agging.txt

find /mnt/emage -type f -mtime -90 ! -mtime -60 -exec ls -la {} \; > 90days.txt
cat 90days.txt | awk '{ SUM += $5} END { print "90days " SUM }' >> agging.txt

find /mnt/emage -type f -mtime -180 ! -mtime -150 -exec ls -la {} \; > 120days.txt
cat 120days.txt | awk '{ SUM += $5} END { print "120days " SUM }' >> agging.txt

find /mnt/emage -type f -mtime -365 ! -mtime -335 -exec ls -la {} \; > 365days.txt

cat 365days.txt | awk '{ SUM += $5} END { print "365days " SUM }' >> agging.txt
 
cat agging.txt | awk '{ $2=$2/1073741824 ; print $1 "," $2 }' > agging.csv

mv agging.csv age.csv
rm agging.txt


Scripts B - Profiler

Code:
 
#!/bin/sh
 
ls -lR | egrep ^- > test.txt

Type[1]='"\.avi\$|\.mov\$|\.mp3\$"'
LABEL[1]=Media
 
Type[2]='"\.doc\$|\.xls\$"'
LABEL[2]=Document
 
Type[3]='"\.png\$"'
LABEL[3]=Image
 
for count in 1 2 3;
do
  echo ${LABEL[$count]},`eval egrep ${Type[$count]} test.txt |awk '{ SUM += $5} END { SUM=SUM/1073741824 ; print SUM" GB"}'`
done
 
# Available space
df -P /mnt/emage | awk 'NR==2{print "Available,"$4/1048576" GB"}'

It is posible scripts A follow as scripts B?
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Detailed disk usage versus age summary

Hi, I'm posting my question here as I fele that what I am about to try to do must have been done already, and I don't want to re-invent the wheel. I have recently become responsible for monitoring disk space usage for a large file system. I would like to geenrate reports that will summise... (8 Replies)
Discussion started by: littleIdiot
8 Replies

2. Solaris

Disk Storage Need to Add more Disk

Hi, Anyone can help me, just want to confirm, if possible adding a disk storage that we have a RAWDATA with +ASM in our database. If possible, what would you recommend "workaround used" from us to do and the preparation. And also how long the downtime will take. Our disk continuous to grow,... (0 Replies)
Discussion started by: fpalero
0 Replies

3. Red Hat

storage disk details

Hi, We have a OEL5.7 installed and which has a storage attached on it. While running application it shows poor performance for Disk IO "dm-0" Now the question is how do I find what exactly is "dm-0" # iostat Linux 2.6.32-100.23.1.el5 03/10/2012 avg-cpu: %user %nice %system... (9 Replies)
Discussion started by: shrshah64
9 Replies

4. Shell Programming and Scripting

File representing the hard disk storage device

I want example of a file representing the hard disk storage device In UNIX ? (6 Replies)
Discussion started by: tamer11007
6 Replies

5. AIX

Need to know %age disk busy on AIX

Hi , Following alerts are coming for %busy device on a server Disk Device hdisk5 is 100% busy Please assist how do I analyse this and also how do I check the %age busy for hdisk5. Best regards, Vishal (4 Replies)
Discussion started by: Vishal_dba
4 Replies

6. Linux

Move OS to storage disk

Hi We have RHEL 7.3 running from local disk and we want to move it to storage. I am unable to find any proper procedure to do this activity. Please help. (4 Replies)
Discussion started by: powerAIX
4 Replies
ff_vxfs(1M)															       ff_vxfs(1M)

NAME
ff_vxfs: ff - fast find: list file names and statistics for a VxFS file system SYNOPSIS
num] num] inode-list] num] file] prefix] special... DESCRIPTION
reads the inode list and directories of each special file, assuming it to be a VxFS file system, and prints inode data for files that match the selection criteria. Output consists of the pathname for each saved inode, plus any other file information requested using the print options below. Output fields are positional. The output is produced in inode order; fields are separated by tabs. The default line pro- duced by is: pathname inumber The pathname is preceded by a dot unless you specify the generic option. The maximum information displays is: pathname inumber size owner The num parameter in the options descriptions is a decimal number, where means more than num days, means less than num days, and num means exactly num days. A day is defined as a 24-hour period. prints summary information to standard error output in addition to the report sent to standard output. Options recognizes the following options: Select a file if the inode has been accessed in num days. Select a file if the inode has been changed in num days. Specify the VxFS file system type. Generate names for any inodes specified in the inode-list. Do not display the inode number after each pathname. Generate a list of all pathnames for files with more than one link. Select a file associated with the inode if it has been modified in num days. Select a file associated with an inode if it has been modified more recently than the specified file. Add the specified prefix to each pathname. The default prefix is dot Print only special files and files with set-user-ID mode (VxFS-specific option). Write the file size, in bytes, after each pathname. Write the owner's login name after each pathname. Echo the completed command line, but performs no other action. The command line is generated by incorporating the user specified options and other information derived from This option allows the user to verify the command line. Operands recognizes the following operand: special Name of a VxFS file system. EXAMPLES
List the pathnames and inumbers of all files in the file system Same as above, but suppress the printing of inumbers: List files on the same file system that have been modified in the last two days displaying the pathname, inumber, and owner's user name List all files on the same file system, including the pathname and inumber of each file, that were last accessed more than 30 days ago Find all pathnames associated with inodes and Execute the command on a VxFS file system FILES
Static information about the file systems. SEE ALSO
find(1), ff(1M), ncheck_vxfs(1M), fstab(4). ff_vxfs(1M)
All times are GMT -4. The time now is 11:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy