Using a simple pipeline you can get the current size of a file. Wrapping that in a script and setting a threshold would allow you to trap a file size. The following examples were executed in ksh on a Solaris 8 system but should be sufficiently generic:
Code:
$ ls -l /var/log/syslog
-rw-r--r-- 1 root root 4109 May 18 07:30 /var/log/syslog
$ ls -l /var/log/syslog | tr -s " " "\t" | cut -f5
4109
Save that as a variable and compare:
Code:
FILESIZE=$(ls -l /var/log/syslog | tr -s " " "\t" | cut -f5)
if [ $FILESIZE -lt 10000 ]
then
: # no action required
else
echo "$FILESIZE" | mailx -s "file limit reached" root
fi
And as my grandmother always said, "season to
your taste." I hope this helps.