实战-将/opt目录下所有的日志文件全自动打包
[root@xuegod63 ~]# vim log-back.sh
#!/bin/sh SRC_DIR=/var/log/ DES_DIR=/opt/backup/`date +%Y%m%d` if [ ! -d $DES_DIR ] ; then mkdir -p $DES_DIR fi for i in `find $SRC_DIR -name "*.log"` do tar czf $i.tgz $i done mv /var/log/*.tgz $DES_DIR ls -lh $DES_DIR echo "The scripts exec end, Files tar successfully !"