One, the script
#!/bin/sh
Dir=/data/ascenlink/logs
#T = ' Find $DRI/*-type f-mtime +365 '
#rm-RF $T
i=$ (df-h |grep-v data2 |awk '/data/{gsub ("'% '", "");p rint $4} ')
If [$I-gt];then
MV $DIR/*.tar.gz/data2/backuplog
echo "No enough free Disk Space for backup" >>/home/ascenlink/backuperror.log
Fi
While True
cpu=$ (vmstat 1 1 |awk ' {print $13} ' |sed-n 3p)
mem=$ (free-m |awk '/mem/{print $} ')
Do
if [[$CPU-GT 90]] | | [[$MEM-GT 8000]];then
Sleep 5m
Else
Break
Fi
Done
#DATE = ' DATE +%y-%m-%d%h%m '
cd/data/ascenlink/logs/
#LOG = ' Find '/-type f-mtime-31-print |xargs '
#wait
#tar-zcvf/data/ascenlink/logs/ascenlink. $DATE. tar.gz $LOG >/dev/null 2>&1
A= ' date-d '-1 months "|awk ' {print $} ' |sed-n 1p '
Date= ' date-d '-1 months "+%y-%m-%d%h%m '
Tar-zcvf/home/ascenlink/ascenlink. $DATE. tar.gz $ (ls-l |grep $A |awk ' {print $9} ') >/dev/null 2>&1
Second, the regular implementation of the task time
Execution time is monthly, 1:1 the log files for the previous one months are packaged
Cat/etc/crontab
1 1 1 */1 * ascenlink/bin/sh/home/ascenlink/logbackup.sh >/dev/null 2 >&1
2010-02-21
This article is from the "Five Corners" blog, please be sure to keep this source http://hi289.blog.51cto.com/4513812/1764636
Linux regular backup scripts-optimized finalization