#!/bin/bash
source /etc/profile
ll /home/|grep bak > /tmp/1.txt
date > /tmp/2.txt
A=`awk '{print$6}' /tmp/1.txt`
B=`awk '{print$7}' /tmp/1.txt`
C=`awk '{print$8}' /tmp/1.txt`
a=`awk '{print$2}' /tmp/2.txt`
b=`awk '{print$3}' /tmp/2.txt`
o=`awk '{print$4}' /tmp/2.txt`
echo $o > /tmp/3.txt
c=`awk -F : '{print$1":"$2}' /tmp/3.txt`
if [ $A == $a ]
then
{
if [ $B == $b ]
then
{
if [ $C == $c ]
then
{
if [ -d /home/bak/$(date +%Y-%m-%d) ]
then
{
cp -r /home/bak/*.war /home/bak/$(date +%Y-%m-%d)
cp -r /home/bak/*.war /home/tomcat-7.0/webapps/
echo "redistribution"
}
else
{
mkdir /home/bak/$(date +%Y-%m-%d)
cp -r /home/bak/*.war /home/bak/$(date +%Y-%m-%d)
cp -r /home/tomcat-7.0/webapps/* /home/bak/$(date +%Y-%m-%d)
echo "release"
}
fi
}
else
echo "time"
fi
}
else
echo "days"
fi
}
else
echo "weeks"
fi
HWQH - 学习,学习!赚钱,赚钱!
请把该脚本设置成计划任务每分钟执行一次进行测试,把/home/bak目录做成ftp家目录,上传到服务器/home/bak目录下的WAR包,该脚本会自动发布并备份
编辑回复