A bit of (Linux) scripting help needed

jibbajabbajibbajabba Member Posts: 4,317 ■■■■■■■■□□
I install you all sorts of Linux cluster and configure the world, but what I never really learned (about time I know) is shell / bash scripting :)

Once a month I go through my Linux server and zip up the weblogs with an awefully simply poor writen DIY script.
custnum=1
for customer in `ls /home | grep -v mysql | grep -v titan`
do
echo $custnum
cd /home/$customer/logs
tar cvfz jun2008.tar.gz log.200806*
for logfile in log.200806*
do
rm $logfile
echo $logfile
done
custnum=`expr $custnum + 1`
done

What I am looking for is finding a way to use a cronjob instead without manually changing these lines
tar cvfz jun2008.tar.gz log.200806*
for logfile in log.200806*

I need a way for the script to query the previous month (script should run 1st of the month) and "zips" up the logfiles accordingly. So if i.e. the script runs February 1st, is should automaticlly go through every folder and tar up all log.201001*

Makes sense ?

Any help is highly appreciated ..
My own knowledge base made public: http://open902.com :p

Comments

Sign In or Register to comment.