unix脚本打包

    技术2025-03-07  46

    ls -l|while read linedomonth='echo $line|awk '{print $6}''day='echo $line|awk '{print $7}''time='echo $line|awk '{print $8}''file='echo $line|awk '{print $9}''if[$month="RIGHTMONTH" -a $day="RIGHTDAY" -a $time="RIGHTTIME"]then continueelse tar $filrfi doneRIGHTMON RIGHTDAY RIGHTTIME  rm if["$month"="Jul" -a "$day="29"]

    ---------------------每次用户登录之后就备份前一天的目录---------------echo '#####程序开始执行#####'CURR_DAY=`date +%d`CURR_MONTH=`date +%m`CURR_YEAR=`date +%Y`C_DAY=`expr $CURR_DAY - 1`directory=`date +%Y%m%d`TARGET=`echo $CURR_YEAR-$CURR_MONTH-$C_DAY`yesterday=`TZ=EAT+16 date +%Y_%m_%d` ####这是得到昨天的日期####yesterday_directory=`TZ=EAT+16 date +%Y%m%d`######################下面是将前天的目录文件夹打tar包#######################if [ $CURR_DAY -eq 01 ];then        if [ -f "$yesterday.tar" ];then                echo '#######此文件已经存在#######'        else                tar -cvf /xiaad/$yesterday.tar /xiaad/$yesterday_directory/        fielif [ -f "$TARGET.tar" ];then        echo '*************此文件已经存在**************'else        tar -cvf /xiaad/$yesterday.tar /xiaad/$directory/fiecho '######程序已经结束########'

    最新回复(0)