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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

size of file alert

Status
Not open for further replies.

billy1

Technical User
Sep 16, 2002
73
IE
Hi,

Does anybody know of a script that will tell me when a file is just about to reach a certain size. We have a file which we don't want going over 2GB so when it's approaching this size it would be handy to get an email alerting us.

Any ideas ?
 
#!/bin/ksh
chkfilesize=`ls -l myfile|awk '{print $5}'`
if[ chkfilesize -gt 2000000000 ]
then
mail -s "File Size exceeded" username
fi

should do it ! Dickie Bird (:)-)))
 
there's more :
Call the above script from the cron every hour/day
or whatever suits. Dickie Bird (:)-)))
 
shouldn't it be:

typeset -i chkfilesize=`ls -l myfile|awk '{print $5}'`
if[ ${chkfilesize} -gt 2000000000 ] vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top