编写shell脚本运行java项目
#!/bin/sh #查询删除源文件包 cd /srv/backups; find -name *.jar | xargs rm -rf echo "删除原备份成功 " #先查询/srv/zjzdd下的文件,然后备份文件到backups目录下,在删除源文件 cd /srv/zjzdd; cp /srv/zjzdd/zjzdd-app-1.0-SNAPSHOT.jar /srv/backups; find -name *.jar | xargs rm -rf echo "备份成功 "
以上是备份操作
下面是运行shell操作
#!/bin/sh #停止java项目 echo "--------Stop java--------" function stop(){ echo "zjzdd-app-1.0-SNAPSHOT.jar "$1 cmdCommand="ps -ef | grep zjzdd-app|grep "$1"|grep -v grep|awk ‘{print \$2}‘" echo $cmdCommand eval "pid=\`"$cmdCommand"\`" if [ -n "$pid" ] then #!kill -9 强制终止 echo "pid:" $pid # kill -9 $pid for i in $pid do echo "kill -9 的pid:" $i kill -9 $i done fi } echo "--------Stop java End--------" #启动java项目 echo "--------Start java--------" function start(){ cd $1 javaCommand="nohup java -jar "$1" --spring.profiles.actives=prod --server.port=8080>nohup.out 2>&1 &" echo "execute start:"$javaCommand eval $javaCommand echo "execute end:"$javaCommand } echo "--------Start java End--------"
相关推荐
huha 2020-10-16
laisean 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
JohnYork 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
wangzhaotongalex 2020-09-22
流年浅滩 2020-10-23
liujianhua 2020-10-22
woaimeinuo 2020-10-21
tufeiax 2020-09-03
laisean 2020-09-01
vvu 2020-09-16
libao 2020-09-16
Yyqingmofeige 2020-08-18
zhushixia 2020-08-17