Aging file not use and touch


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Aging file not use and touch
# 1  
Old 04-13-2011
Aging file not use and touch

Hi all,

Need advice from expect, below is my scripts to find the file not use and touch in storage and other directory.

This scripts divide by:

1. 30 days
2. 90 days
3. 180 days
4. 1 years
5. 3 years
6. 5 years

Then count total size in GB from 6 each category.

Sample my scripts:
Code:
 
# 30 days
find /mnt/emage -type f -mtime -30 ! -mtime -0 -exec ls -la {} \; > 30days.txt
cat 30days.txt | awk '{ SUM += $5 } END { printf "30days,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
# 90 days
find /mnt/emage -type f -mtime -90 ! -mtime -60 -exec ls -la {} \; > 90days.txt
cat 90days.txt | awk '{ SUM += $5 } END { printf "90days,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
# 180 days
find /mnt/emage -type f -mtime -180 ! -mtime -150 -exec ls -la {} \; > 180days.txt
cat 180days.txt | awk '{ SUM += $5 } END { printf "180days,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
# 1 Years
find /mnt/emage -type f -mtime -365 ! -mtime -335 -exec ls -la {} \; > 1years.txt
cat 1years.txt | awk '{ SUM += $5 } END { printf "1years,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
# 3 Years
find /mnt/emage -type f -mtime -1095 ! -mtime -1005 -exec ls -la {} \; > 3years.txt
cat 3years.txt | awk '{ SUM += $5 } END { printf "3year,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
# 5 years
find /mnt/emage -type f -mtime -1825 ! -mtime -1675 -exec ls -la {} \; > 5years.txt
cat 5yeras.txt | awk '{ SUM += $5 } END { printf "5year,%.2f\n",SUM /1024^3 }' >> aging_temp.csv

Code:
 
mv aging_temp.csv aging.csv

Thanks.
# 2  
Old 04-13-2011
What is your question?

Code:
find /mnt/emage -type f \( -mtime -1825  -a -mtime +1675 \) -exec ls -la {} \;

Your syntax may want to change to the above as well. This example is:
less than 1825 days and greater than 175 days, using POSIX-compliant syntax for find.
# 3  
Old 04-13-2011
Thanks Jim Mcnamara.

My question is just only need expert in this forum verify and comment my scripts. Maybe have better scripts other than this.

From your post:
Code:
find /mnt/emage -type f \( -mtime -1825  -a -mtime +1675 \) -exec ls -la {} \;

This scripts maybe I can put in as 5 years aging. I have question for +1675, how do you calculate and get this figure?. What I understand -1825 is equal to 5 years.

How about 30 days, 90days, 180days, 3years, 1years and 5 years already have it.

Thanks.
# 4  
Old 04-14-2011
Another way to do it would be to loop through all the files something like this:
Code:
for f in $(find /mnt/emage -type f); do
    # examine and classify $f
done

This command will give you the file's age in seconds: date -r "$f" +%s

This command does the same: stat -c%Y "$f"

The current time in seconds: date +%s

The file's size in bytes: stat -c%s "$f"

You might be able to make a nicer script with the individual pieces.
# 5  
Old 04-14-2011
Thanks KenJackson,

I'm not understand, so sorry. Can you explain me how to run this script? and guide me to this in detail?

Thanks again.
# 6  
Old 04-14-2011
I didn't have time to write the script.
I just mentioned the commands that would be used to do it a different way.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using touch to create a file

I have noticed that the following command works touch subtext_geopdf_to_.x However this one does not touch subtext_/geopdf/_to_/.x How can I create such a file without making it think I supplied a path? (2 Replies)
Discussion started by: kristinu
2 Replies

2. UNIX for Dummies Questions & Answers

Protect a file against touch

Afternoon, the stat command is used against a file to ascertain date created and last modification time. However a different individual if they so chose could use the touch command to alter the date created or modification time. Is there anyway to protect against this ? thanks Steve (2 Replies)
Discussion started by: sevans29
2 Replies

3. Shell Programming and Scripting

[Need HELP] Find aging file and auto FTP

Dear Experts, I have script to find aging file like this: find /ArchiveINTF/INTF name "*" -type f -mtime +365 {} \; >> agingfile.txt This script will find all files over 365 days. But, I have problem, how to auto FTP all files? Thanks Edy (3 Replies)
Discussion started by: edydsuranta
3 Replies

4. Shell Programming and Scripting

[HELP] Scripts moving aging file by FTP

Hi Experts, Kindly share scripts to find aging file and ftp to another server.. Example: Find files more than 5 days and ftp to another server. Please give suggestion :) Thanks Edy (1 Reply)
Discussion started by: edydsuranta
1 Replies

5. Shell Programming and Scripting

SCP and then touch .done file

All, I am looking to make a script and wanted to see if anyone could help out. The script will go through the directory, put a timestamp, transfer it and then create a touch $file.done script HEre is my initial idea, but I don't think it will work properly. Anyone able to help me refine it... (11 Replies)
Discussion started by: markdjones82
11 Replies

6. Shell Programming and Scripting

Touch New File with First Line

I am interested in creating a new file from a KSH script where the first line is printed. I know how to create the file, but creating with a pre-defined first line is what I need help with. My code below creates the file, but how do I accomplish that and do it so that when I open that txt file... (5 Replies)
Discussion started by: royarellano
5 Replies

7. UNIX for Dummies Questions & Answers

Touch all files and subdirectories (recursive touch)

I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks! I tried something i found online, find . -print0 | xargs -r0 touch but I got the error: xargs: illegal option -- r (5 Replies)
Discussion started by: glev2005
5 Replies

8. UNIX for Dummies Questions & Answers

password aging

hi experts this is regarding password aging i tried searching forum but i cudnt locate given a login id, i would like to determine whether password ageing has been enabled for that and for the login id whether password has been expired on a particular point of time Thanks (4 Replies)
Discussion started by: teletype_error
4 Replies

9. UNIX for Dummies Questions & Answers

password aging help

If the command passwd -f is used, Users get the below error. I need to force users to change there passwords at initial login. Anyone know what is going on? This is on a Non-Stop UX system UX:in.login: ERROR: Your password has been expired for too long UX:in.login: TO FIX: Consult your system... (0 Replies)
Discussion started by: breigner
0 Replies

10. UNIX for Advanced & Expert Users

OpenSSH and password aging

Vesion 3.8.1 of OpenSSH has been compiled on a Solaris 8 host. I am having difficulties in enabling password aging to work from reading /etc/default/passwd and /etc/shadow. # passwd -f < user-id > works satisfactorily however once a password ages through due course from the settings in... (1 Reply)
Discussion started by: raylen
1 Replies
Login or Register to Ask a Question