How to check if my log file is growing properly?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to check if my log file is growing properly?
# 1  
Old 08-20-2014
How to check if my log file is growing properly?

Hi All,

I want to check if one my log file is updating properly, how can I achieve it.
The approach I am trying is to get the file size at two different interval and than comparing it eg :
Code:
[puttyuser@voda_ggn ~]$ ls -ltr | tail -1 | awk '{print $5}'
20480


Last edited by rbatte1; 08-20-2014 at 08:23 AM.. Reason: Capitalised first person singular
# 2  
Old 08-20-2014
If you are trying to get information about a file, why not ask about that file explicitly with:
Code:
ls -l File

instead of hoping that:
Code:
ls -ltr DirectoryContainingFile | tail -1

will give you information about the file you want???
# 3  
Old 08-20-2014
Why not use stat (or equivalent, if available)?
# 4  
Old 08-20-2014
Hi Don,

Thanks for your info but this is the log file and a new file gets create after exceeding a certain size limit, in this way I am sure to get the size of latest file
Code:
ls -ltr DirectoryContainingFile | tail -1 | awk '{print $5}'

@RudiC - I have never used stat, let me try to find how it works.

Last edited by rbatte1; 08-20-2014 at 08:24 AM.. Reason: Capitalised first person singluar
# 5  
Old 08-20-2014
The stat command utility is available mostly on Linux distributions.
# 6  
Old 08-20-2014
Code:
sfile=/tmp/logsize
size=`ls -ltr | tail -1 | awk '{print $5}'`
if test -f $sfile &&
 read osize < $sfile &&
 test $osize = $size
then
 echo "logfile not growing"
fi
echo $size > $sfile

# 7  
Old 08-20-2014
Some considerations.

Most modern kernels maintain a memory cache of pages written to files. The dirty (changed or added data) pages get written to disk physically - when the system does a fflush (or equivalent) call. Which is not always RIGHT NOW. Also file mtime and atime updates may be deferred until the file descriptor is actually closed. All of this is kernel-dependent and depends what kind of file system is in use (plus mount options).

What this means:
1. Please post your OS name and version
2. the fstab or vfstab (in /etc ) entry for your filesystem.

Why?

The answers given will very probably work for you, but may not always be both timely and correct, which is what you seem to want. Constant runs of RudiC's nice little script may not show you that data was sent by the logging program to the log - until a cache flush occurs. This may be every 30 seconds or so, whenever your sync daemon runs. If you have one. That is why we ask those two questions.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Incremental extract from growing log file.

We have a log file which has 16 million row. We want to read all the lines appended from the last time we read using sed command sed -n '<START_LINE>,<LAST_LINE>p' abc.csv I can store this last line line so I can give replace that with START_LINE in my next read. The problem is wc -l which... (2 Replies)
Discussion started by: one2connect
2 Replies

2. Shell Programming and Scripting

Error check for copying growing directories

I have a simple script which copies directory from one place to another and deleting the source . I am facing a situation when new files gets added when the script has started running. Its resulting in data loss Please suggest a way to avoid data loss. I googled a lot but most are perl... (11 Replies)
Discussion started by: ningy
11 Replies

3. Shell Programming and Scripting

Check log file size every 10 minute. Alert if log not update

How to check log size every 10min. by script (can use crontab) if log size not change with alert "Log not update" Base run on SunOS 5.8 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise logFiles="log1.log log2.log" logLocation="/usr/home/test/log/" Out put. Tue Jan 31... (3 Replies)
Discussion started by: ooilinlove
3 Replies

4. UNIX for Dummies Questions & Answers

Find the file which is growing at high speed

Hi, A log file which is growing at high speed, don't know the name of it. How to find the respective file? Many thanks. (2 Replies)
Discussion started by: venkatesht
2 Replies

5. Solaris

Growing a file system-SVM

Hi gurus Im a newbie in solaris..I need to extend file system space in solaris 10 which is using SVM..I have a file system /pin02 which is 93% full n needs to be extended..only 3.6 gb avail space left..the file system is not mirrored...normal ufs file system only..can u please tel me t... (6 Replies)
Discussion started by: madanmeer
6 Replies

6. Shell Programming and Scripting

FTP check if file exists and log it

Hi, I need to create a script that checks if a file exists on an offsite server which only has ftp enabled. I was originally going to use perls Net::FTP class but the client does not have perl installed nor wants it. So, I have to use a shell script which logs into the server, then ... (1 Reply)
Discussion started by: gseyforth
1 Replies

7. HP-UX

how to redirect the growing contents of log file to another file in unix

how to redirect the growing contents of log file to another file in unix (2 Replies)
Discussion started by: megh
2 Replies

8. UNIX for Dummies Questions & Answers

Find out the maximum growing file in a mount

I need to find the file that is growing in the mount. Say yesterday the utilised space was 95% but today that is 96%. How do i find the file that is growing in size. Have checked the same with du/df options but was not able to find much. Please suggest the best possible option. (3 Replies)
Discussion started by: raman1605
3 Replies

9. UNIX for Dummies Questions & Answers

.osm file growing

my /etc/.osm file is growing rapidly and logging large amounts of activity. Can anyone tell me what this file is for and what types of information is logged in this file. Thanks in advance for your help!! (1 Reply)
Discussion started by: golfs4us
1 Replies

10. UNIX for Advanced & Expert Users

How to check a file in UNIX is closed or growing?

We have a third party tool in UNIX to kick off a 'file copy' job based on a file existance. If a specific file exists in an UNIX directory, another process should start copy the file into another system for further processing. The issue is, the copy job is starting as soon as the file exists in... (6 Replies)
Discussion started by: kslakshm
6 Replies
Login or Register to Ask a Question