![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Disk quota exceeded...... | thehaapyappy | UNIX for Dummies Questions & Answers | 8 | 05-13-2008 10:07 AM |
| File size limit exceeded... SCO ulimit? | rm -r * | UNIX for Dummies Questions & Answers | 1 | 10-22-2007 02:52 PM |
| File size limit exceeded | drshah | High Level Programming | 13 | 03-02-2006 11:11 PM |
| SCO Openserver 5.0.7 NSTRPAGES Exceeded | josramon | UNIX for Dummies Questions & Answers | 2 | 08-02-2005 12:29 PM |
| check logfile size | dozy | Shell Programming and Scripting | 4 | 05-27-2003 03:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You can do something like:
Code:
#!/bin/ksh
used=`du -b logfile|awk '{print $1}'`
if [ "$used" -gt 1024 ]; then
# do your stuff here
fi
|
|
#3
|
|||
|
|||
|
ThanQ Franklin !!!
|
|
#4
|
|||
|
|||
|
#! /usr/bin/ksh
interval=900 ## check for logfile size once in this much seconds while true ; do size_of_file=`ls -l logfile | awk '{ print $5}'` if [ ${size_of_file} -ge 1024 ] then datestamp=`date "+%m%h%Y_%H%M%S" cp logfile /archive/logfile.${datestamp} ## take an archive cp /dev/null logfile fi sleep $interval done |
|||
| Google The UNIX and Linux Forums |