yun.sh脚本
作者:
黑客不黑_ | 来源:发表于
2019-04-11 18:25 被阅读0次DATE=$(date +%Y%m%d%H%M%S)
export JAVA_HOME PATH CLASSPATH
JAVA_HOME=/home/service/jdk1.8.0_191
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
DIR=/home/www/new-retail/new-retail-manager/web/
JARFILE=bh-back-manager.jar
if [ ! -d $DIR/backup ];then
mkdir -p $DIR/backup
fi
cd $DIR
pid=`ps -ef | grep bh-back-manager.jar | grep -v grep | awk '{print $2}'`
echo "---------------"
for id in $pid
do
kill -9 $id
echo "killed $id"
done
echo "---------------"
echo "授予当前用户权限"
echo "执行....."
cp $JARFILE backup/$DATE$JARFILE
java -Xmx500m -jar $DIR$JARFILE > /home/log/bh/new-retail/back/bh-back-web.log &
if [ $? = 0 ];then
sleep 20
tail -n 50 /home/log/bh/new-retail/back/bh-back-web.log
fi
cd /home/log/bh/new-retail/back
# 删除七天前产生的日志
ls -lt|awk 'NR>5{print $NF}'|xargs rm -rf
cd backup/
# 删除 五天前产生的备份文件
ls -lt|awk 'NR>5{print $NF}'|xargs rm -rf
echo "执行成功"
本文标题:yun.sh脚本
本文链接:https://www.haomeiwen.com/subject/xmuxwqtx.html
网友评论