Saturday 16 May 2009

run a script just like cron using setsid command

I wanted to collect statistics of my files (like.. num.of lines, total size of the line , i run as a key_count.sh script) .This is how i ran my script which will be executed in a seperate shell.

Here is my script :

bash$cat count.sh

#!/bin/sh

FILENAME=/ghostcache/tmp/sperumal_key_count/data.out
#eval $(date | awk '{print "month="$2";day="$3}')
#d=`expr $day - 1`
#echo "Starting:" >> $FILENAME

while :
do
echo "Starting:" >> $FILENAME
date >> $FILENAME

eval $(date | awk '{print "month="$2";day="$3}')
d=`expr $day - 1`

/ghostcache/sriram/key_count.sh $month $d "file1_[0-9]+" >> $FILENAME
/ghostcache/sriram/key_count.sh $month $d "file2_[0-9]+" >> $FILENAME
/ghostcache/sriram/key_count.sh $month $d "file3_[0-9]+" >> $FILENAME
/ghostcache/sriram/key_count.sh $month $d "file4_[0-9]+" >> $FILENAME
/ghostcache/sriram/key_count.sh $month $d "file5_[0-9]+" >> $FILENAME
/ghostcache/sriram/key_count.sh $month $d "file6_[0-9]+" >> $FILENAME

sleep 86400
done

Run using setsid :

bash$setsid count.sh

No comments:

Post a Comment

Tweets by @sriramperumalla