check logfile size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check logfile size
# 1  
Old 05-22-2003
check logfile size

Hello everyone!

Can anyone help me with this?

I need a script that looks at a logfile and check itīs size. If itīs over a sertain size the i should get an email. Dont really know how the grep that info "the size"

Please help....
# 2  
Old 05-22-2003
FILE="my_log_file"
SIZE=123456
VAR=`ll $FILE | awk -F" " '{print $5}' `

if [ $VAR -gt $SIZE ]
then
mail me a message
fi

I cant remember if the file size is field 5 or not...check that.
# 3  
Old 05-24-2003
I don't know about the ll command used above, but I think if it doesn't work for you then replace ll $FILE with wc -c $FILE. wc -c will give you the count of bytes of file $FILE.

FILE="my_log_file"
SIZE=123456
VAR=`wc -c $FILE | awk -F" " '{print $1}' `

if [ $VAR -gt $SIZE ]
then
mail me a message
fi

Regards,
Yeheya
# 4  
Old 05-24-2003
FILE="my_log_file"
SIZE=123456
VAR=`wc -c $FILE | awk -F" " '{print $1}' `

if [ $VAR -gt $SIZE ]
then
mail me a message
fi


Either method should work. The long list will just print out the long listing entry for the file in question which then awk will pick off the file size. wc cuts out the file size and then awk prints it. Either method should work....pick the method that works best for you.
# 5  
Old 05-27-2003
thanx that did the trick!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logfile monitoring with logfile replacement

Bonjour, I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things. The script use the following technique : tail -fn0 $logfile | \ while read line ; do ... some stuff done First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies

2. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

3. Shell Programming and Scripting

File size check

I am trying to check whether two files are empty or not using below if condition but its checking for only one file if ] Again I tried if && ] Need your assistance (2 Replies)
Discussion started by: Aditya_001
2 Replies

4. SCO

check partitions size in MB

hi Howto check partitions size in MB on SCO 5.0.6? Using df command I can see just in blocks. (4 Replies)
Discussion started by: ccc
4 Replies

5. UNIX for Advanced & Expert Users

Check latest time where theres the word 'processed' in logfile

Hi, Im doing a project to check the latest time with the word 'processed' in a logfile. the time range is within 2 hours before the curent datetime to present. For example: Current datetime is 'October 6 2009 8:00AM' --- HKT So the time range that need to check is from 'October 6... (1 Reply)
Discussion started by: romanne
1 Replies

6. UNIX for Dummies Questions & Answers

Check the size of files

Hi, I need to put a script working to see in a directory with logs if exists file or files with size more than 12Mb. If exists it shoul send mail. Can anyone help me? thanks (3 Replies)
Discussion started by: osramos
3 Replies

7. Shell Programming and Scripting

To check file size

Hi All, I am in small problem.. i have one script which transfers some big files to my ftp usign normal command like put .... my problem is how to check whether my file have been transferred successfully on ftp or not... i know only inside ftp we have option like 'size' command which... (2 Replies)
Discussion started by: Shahul
2 Replies

8. Shell Programming and Scripting

Logfile Size exceeded ????

Hi, How to write a script which checks the size of a log file? I want that the log file contents to get cleared as soon as it increases 1 KB. Thanks (3 Replies)
Discussion started by: skyineyes
3 Replies

9. UNIX for Dummies Questions & Answers

How to check directory size

how say I have directory how can I get the directory size in mega and if it less then 1 mega so byts Thanks (4 Replies)
Discussion started by: umen
4 Replies

10. UNIX for Dummies Questions & Answers

Check file size

I need a unix script that will check the size of multiple files in the same directory or from a text file. (6 Replies)
Discussion started by: alnita
6 Replies
Login or Register to Ask a Question