This shows you the differences between two versions of the page.
custom_log_rotate_script [2009/06/04 15:01] k2patel created |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Custom Log rotate script ==== | ||
- | |||
- | <code bash | custlogrotate.sh> | ||
- | #!/bin/sh | ||
- | |||
- | yesterday=`date -v-1d '+%Y%m%d'` | ||
- | |||
- | mkdir /home/log/log.$yesterday | ||
- | |||
- | for i in `ls /home/log | grep $yesterday` | ||
- | do | ||
- | echo $i | ||
- | mv $i /home/log/log.$yesterday | ||
- | done | ||
- | |||
- | tar -cvf /home/log/log$yesterday.tar.gz /home/log/log.$yesterday | ||
- | rm -rf /home/log/log.$yesterday | ||
- | chown -R user:group /home/log | ||
- | </code> | ||