Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Monitor one specific directory for .dat files

Status
Not open for further replies.

TigrePanthera

Technical User
Oct 9, 2010
1
0
0
US
Experts et al,

Hello !

I feel down right stupid to ask this question but Im not sure as to where to go on this one.

Task at hand - Monitor one specific directory for .dat files and if there are more than 10 files in there then you need to send out an email saying that there are 10 files in there. Also, I cannot set up a Cron job in there and hence I need a counter driven one which goes in there for every 60 mins or so and checks to see if there are any new *.dat files and if there are more than 5 at the end of each hour, please send an email.

Here is what I have but this is no way near completion. So help me out.

regards,
Varun.

Code:
#!/bin/ksh
for FOLDER in `find ./Applications/ -type d -mindepth 1 -maxdepth 1`;
do
COUNT=`ls *.dat | wc -l`
if [ "$COUNT" -gt 5 ]; then
echo "The number of files in the directory are :$CNT"
mailx -s "Need to look at this Directory" ard@test.com
fi
sleep 3600;
done
 
Hi there,

first question that comes to my mind:
What's wrong with using a cronjob ?

Otherwise you could use an /etc/inittab entry and extend your script like that:

Code:
while [ 1=1 ];
do
... your script ...
done

Regards,
Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top