Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am new to the UNIX operating system, and have a small task to be accomplished. Every thursday I need to check a certain directory
(/etc/custom/logs/ob) and if any files have been added/modified in the past 10 days an email has be sent to me with the new/modified files.I understand that a script has be written along with a cron job which will trigger the script at weekly intervals. But thats where my knowledge ends. Please guide me further.
Thanks,
Collis

OK...of course you know that in cron you'll have to set the verbage to something like this:
0 0 * * * 4 /pathtoshellscript
and of course give it full permissions so that it's executable. Now, for the meat of your question. You'll have to write a script that sounds kinda like this....
$DAYS='cut-c1-2'
$PASTENDAYS='date | cut -c(the numbers of the characters where the day is in the string)' (or something to that effect with some arithmetic subtracting 10 days)cd /etc/custom/logs/ob
l | cut -c(the number of the characters which contain the "date" section AND the "filename" section then...)>>tmp1
for i in 'cat tmp1'
if $DAYS => $PASTENDAYS
then cat $i >>tmp2
else
next i
for a in 'cat tmp2'
echo $a >>finalfile.txt
cat $a >>finalfile.txt
next a---then mail finalfile.txt to yourself---
I'm a little rusty but i hope that helps

The script you need should use the find command. Use the man pages for find and look at -mtime option. The script posted above will not work. Cutting out the days will not provide an allowance for a change in months.
find /dirname -mtime -10 -print
Jerry

Dear Sir.
I wrote a program switching printer job for the users.sometime work sometime doesn't work almost work for me not for users.someone told me to wrote a script for login(we don't want users know the password)and permission for users use lpalt.... when users got to the unix that ask them password: 12345. so I don't know how to write a script for all them,i used nuix command " lpalt Q12-1235 -dQ13".

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |