Hi I want a shell script that will give me a list of files which were last accessed over a specific time ago and want it to use a variable so I can do this...
Rought Example...
#Input time in bracket for how many months.
MONTHSAGO="13"
#Specify the Top Level Directory path you want to
DIR="/Share_Points/"
#Specify the output filename
FILENAME="Files_For_Archiving"
Script goes off checks the entire /Share_Points for any file that was last accessed over 13 months ago.
Compiles them into a list with the access date and path to file;
Access Date File
01-01-2008 /Share_Points/Accounts/Reports/2008_Report.XLS
I have no idea on how to achieve this and would absolutely love it if someone could help?
#!/bin/bash
## File Access Report
## Only edit the next 3 lines.
#Days ago to search
DAYS="365"
#TLD path you want to search
DIR="/Macintosh HD/"
#Output filename
FILENAME="/Files_For_Archiving.txt"
#
find $DIR -type f -atime +${DAYS} \; > $FILENAME
Suddenly you directory name contains space characters and must be quoted.
Check thoroughly. The "last accessed time" is pretty volatile and gets changed by reading or changing a file. Some backup software changes that timestamp.
To keep you moving: The script so far produces a list of files for consideration.
#!/bin/bash
## File Access Report
## Only edit the next 3 lines.
#Days ago to search
DAYS="365"
#TLD path you want to search
DIR="/Macintosh HD/"
#Output filename
FILENAME="/Files_For_Archiving.txt"
#
find "${DIR}" -type f -atime +${DAYS} -print > $FILENAME
#!/bin/bash
## File Access Report
## Only edit the next 3 lines.
#Days ago to search
DAYS="365"
#TLD path you want to search
DIR="/Volumes/Macintosh HD/Users/"
#Output filename
FILENAME="/Files_For_Archiving.txt"
#
find "${DIR}" -type f -atime +${DAYS} -printf FORMAT %Ak > $FILENAME
I am trying to use the print command to output the results formatted with a timestamp to my Variable Filename.
This doesn't seem to work or at lest my understanding the argument -print in the find command man page is off track?
Also I understand that backup software may alter the access timestamp but unless I have some long script that compares the <atime> with <mtime> I am unsure what to do. It a policy for archival, what I want to do is compile a list of human readable files (with paths to the file) of files over Xdays old which will mean they get archived off to tape.
If anyone has a better solution I am all ears
But in the mean time I think this script is almost done�? apart from the print formatting to the output file.