unixware ksh 实现定时备份

ksh 实现定时备份

 

------------getdays的脚本
year=`echo $1|cut -c1-4`
  month=`echo $1|cut -c5-6`
  day=`echo $1|cut -c7-8`
  b=`cal $month $year|wc -l `
  cal  $month  $year |awk  '{for(i=1;i<=NF;i++){if($i=='$day'){if (NR=='"$b"'-1)
{print i-1}else{print 7-NF+i-1}}}}'

 

 

 


------------实现每周5冷备份

RUNDATE=`date +%Y%m%d`
DELDATE=`perl date.pl`
DATE=`date +%Ou`
pw=sys/manager
WEEK=`getdays $RUNDATE`;export WEEK
if [ $WEEK -eq 0 ]
then
  WEEK=7;export WEEK
fi


if [ $WEEK -eq 5 ]
then
echo " 开始 冷备份 。。。。。。。"
/home6/backup/admin/coldback1.sh
fi

~

你可能感兴趣的:(Date,脚本,perl)