A bit of (Linux) scripting help needed

in Off-Topic
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.
What I am looking for is finding a way to use a cronjob instead without manually changing these lines
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 ..

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 

Comments
-
maumercado Member Posts: 163
For the date you could use the date command, clean it up with regular expressions or sed... and then pass it as a variable in the name of the file...
hehehe simple...
Check out tldp.org advanced bash scripting or bash guide for beginners -
jibbajabba Member Posts: 4,317 ■■■■■■■■□□
Hehe, yea "that" simple
Well I came so far to show the last month as numberdate +"%m" --date='1 month ago'
and written worddate --date='1 month ago' +%B
Now I have to somehow throw everything in one pot and make a script out of itMy own knowledge base made public: http://open902.com