File Growth Check Script

Posted: July 7, 2011 in CLI, Linux

Hello Guys,

This little script is for cecking on a file growth, and letting us know when the file has finished growing, more updates soon of course but here is the first release. ENJOY


#!/bin/bash
# File Growth Check Script
# Created by wsanriv 7/7/2011
# First input is file Path
# Example: "fgc.sh /tmp/file1"

#Input File path
if [ $# -lt 1 ]
then
    echo "Please give file"
    exit 1
fi
FILE_IN=$1

#Check for empty path or non file path
if [ ! -f $FILE_IN ]
then
    echo "Not a valid file"
    exit 1
fi

#Sample initialization
sample_a=0
tic=0

#Loop for Growth check
while true
    do
    clear
    sample_b=$sample_a
    ls -alh $FILE_IN | grep $FILE_IN
    sleep 1
#---Check if growth stoped
    sample_a=$(stat -c%s ${FILE_IN})
    if [ $sample_a -eq $sample_b ]
    then
    echo "SAME SIZE"
    $tic = ${tic} + 1
    fi
    done

#END
Advertisements
Comments
  1. tingon says:

    at the end of the script
    if [ $ <<<<<< i think it will be an error

    bye

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s