Operating System - HP-UX
1832645 Members
3072 Online
110043 Solutions
New Discussion

Re: Script - for change files other than *.log,*.out,*.tmp

 
SOLVED
Go to solution
Muthyala
Frequent Advisor

Script - for change files other than *.log,*.out,*.tmp

Hi

I need a script to log all the files that have changed in last one day excluding the *.log,*.out,*.tmp files .

I would like the changed files sent to a log file, and have the days changed files emailed.

so, for example, if 5 files change everyday, then only the 5 files of that day will be emailed, BUT, all of the previous files will be retained in the log file....i want to use the log file as an archive, and the email as a notification.

TIA
3 REPLIES 3
Doug O'Leary
Honored Contributor
Solution

Re: Script - for change files other than *.log,*.out,*.tmp

Hey

find ${dir} -mtime -1 -print | egrep -v "\.tmp|\.out|\.log" | \
tee -a ${log} | mailx -s "File changes: `date +%m/%d/%y`" ${addr}

Hope that helps.

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Peter Nikitka
Honored Contributor

Re: Script - for change files other than *.log,*.out,*.tmp

Hi,

the find command can get the files by itself:

find . -mtime -1 ! \(-name '*.log' -o -name '*.out' -o -name '*.tmp' \) -print |
tee -a log |
mailx -s "File changes $(date +%x)" mailaddr

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Arturo Galbiati
Esteemed Contributor

Re: Script - for change files other than *.log,*.out,*.tmp

Hi,
on my hp-ux 11i the rigth syntax is:

find . -type f -mtime 0 ! \( -name '*.log' -o -name '*.out' -o -name '*.tmp' \) |xargs -i ll {}|tee -a logfile |mailx -s subject ajondoe@hotmnail.com

Tips:
-type f: to get only file chnages and not dir or file in subdirs
-mtime 0: to have file chnages from 24 hours ago to now as from man:
-mtime n True if the file modification time subtracted
from the initialization time is n-1 to n
multiples of 24 h. The initialization time
shall be a time between the invocation of the
find utility and the first access by that
invocation of the find utility to any file
specified in its path operands.

xargs -i ll {}: to chek about file date

HTH,
Art