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

My file size is bigger than yours

Status
Not open for further replies.

segment

ISP
Jun 15, 2004
225
US
Greets all... Whipped up something personal which has something else eluding me...

grep -i denied /var/log/access.log |awk '{print $1,$2,$3,$4,$5,$6}' >> /tmp/`date +%b%d`.denied
hour=`date|awk '{print $4}'|sed 's/:/ /g'|awk '{print $1":"}'`
day=`date|awk '{print "2005.9."$3}'`
grep $day /tmp/*.denied|grep $hour

Simple lame script to check for anything denied in a log file which then sends it to /tmp which later emails me from cron. However... When the file is null (usually under 4k) it's still sending me mail... I thought of something like:

size=`ls -la /tmp/*denied |awk '{print $5}'`; if [ $size -gt "4000000" ]; then do something ; else echo die ; fi

Just tired, bored, and out of caffeine.
 
man find

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
For what I'm not trying to find files. Right now I can chmod +x that upper file and run it and it does what it's supposed to do... I don't want to find files in /tmp I wanted to look at /tmp/*.denied and if anything there for the hour was under 4k to ignore it, anything over email it.
 
In the find man page pay attention to the -name and -size primaries.

Another note:
hour=`date "+%H:"`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
find /tmp -name '*.denied' -size +8 -exec mailscript {} \;

find /tmp -name '*.denied' -size +4k -exec mailscript {} \;

filelist=$(find /tmp -name '*.denied' -size +4k -print)

check your find man page


HTH,

p5wizard
 
[root@valhalla firewalk]# whereis myhead
myhead:


;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top