#!/bin/bash# 脚本中只要出现执行不是true的语句,就退出不再往下执行set -e# 导入环境变量export jar_PATH=/data/webexport APP_PATH=/home/# 判断老的进程是否存在,若存在就杀掉killjar(){pid=`ps -ef|grep supplier-center |grep java |awk '{print $2}'`echo "supplier-center Id list :$pid"if [ "$pid" = "" ]thenecho "no supplier-center pid alive"elsekill -9 $pidfi}# 调用函数killjar# 判断老的jar包是否存在,若存在就删除[ -f $APP_PATH/supplier-center-1.0.0-SNAPSHOT.jar ] && \rm -rf $APP_PATH/supplier-center-1.0.0-SNAPSHOT.jar# 更新最新的jar包mv $jar_PATH/supplier-center-1.0.0-SNAPSHOT.jar $APP_PATH# 重新启动nohup java -jar $APP_PATH/supplier-center-1.0.0-SNAPSHOT.jar > \$APP_PATH/admin.log &# sleep 10秒, 等待java进程完成起来sleep 10secho 'Start success!'
sh -x supplier-center.sh #检查脚本是否有问题
#!/bin/bashcd ${WORKSPACE}/supplier-center/targetscp supplier-center-1.0.0-SNAPSHOT.jar 192.168.0.29:/data/webssh 192.168.0.29 "bash /data/sh/supplier-center.sh"
判断都有if语句,否则jenkins会执行不了,还有一个巨坑
#!/bin/bash# 脚本中只要出现执行不是true的语句,就退出不再往下执行set -e# 导入环境变量export jar_PATH=/data/webexport APP_PATH=/opt# 判断老的jar包是否存在,若存在就删除if [ -f $APP_PATH/antSale ]; thenrm -rf $APP_PATH/antSalefi#echo $?#echo "###end###"# 更新最新的jar包if [ -f $jar_PATH/antSale ]; thenmv $jar_PATH/antSale $APP_PATHfi#echo $?
nohup java -jar admin-1.0.0-SNAPSHOT.jar >/dev/null 2>&1& jar启动输出日志到空
jar包引用本地同级配置文件config,解决每次合并分支更改配置文件问题,相对路径可以加个config自动识别配置文件
nohup java -jar -Dspring.config.location=/绝对路径/application.properties /xxx/xxx.jar > /xxx/xxx.log &
#!/bin/bash# 脚本中只要出现执行不是true的语句,就退出不再往下执行set -e# 导入环境变量export jar_PATH=/data/webexport APP_PATH=/home# 判断老的进程是否存在,若存在就杀掉killjar(){pid=`ps -ef|grep supplier-center |grep java |awk '{print $2}'`echo "supplier-center Id list :$pid"if [ "$pid" = "" ]thenecho "no supplier-center pid alive"elsekill -9 $pidfi}# 调用函数killjar# 判断老的jar包是否存在,若存在就删除if [ -f $APP_PATH/supplier-center/supplier-center-1.0.0-SNAPSHOT.jar ]; thenrm -rf $APP_PATH/supplier-center/supplier-center-1.0.0-SNAPSHOT.jarfi# 更新最新的jar包if [ -f $jar_PATH/supplier-center-1.0.0-SNAPSHOT.jar ]; thenmv $jar_PATH/supplier-center-1.0.0-SNAPSHOT.jar $APP_PATH/supplier-centerfi# 重新启动#cd $APP_PATH/supplier-center && \#nohup java -jar /home/supplier-center/supplier-center-1.0.0-SNAPSHOT.jar > supplier-center.log &nohup java -jar -Dspring.config.location=/home/supplier-center/config/application.yml /home/supplier-center/supplier-center-1.0.0-SNAPSHOT.jar > supplier-center.log &# sleep 10秒, 等待java进程完成起来sleep 10secho 'Start success!'
远程(jenkins)调用shell 不能正常结束
例如:nohup java -jar start.jar >log.log 2>&1 &。但是在jenkins远程调用,会把日志打印在jenkins控制台中,导致任务不能结束。通过排查,在程序运行前使用了cd命令,先cd到目录,在运行命令cd /service && nohup java -jar start.jar >log.log 2>&1 &改为绝对路径,去掉cd命令,程序正常了脚本如下:#!/bin/bashset -xkill -9 `ps -ef |grep start|grep -v grep|awk -F " " '{print$2}'`source /etc/profilenohup java -jar /service/start.jar -Xms500m -Xmx500m -Xmn250m -Xss256k -server -XX:+HeapDumpOnOutOfMemoryError > /service/Log.log 2>&1 &echo "starting service..."sleep 10#根据重启后是否有当前应用判断启动是否成功pid=$(ps -ef |grep start|grep -v grep|awk -F " " '{print$2}')#echo $pidif [ -z $pid ];thenecho "启动失败"exit 1elseecho $pid "SUCCESS"fi
jar包配置文件合并之后格式为,数据库-服务名-nacos注册地址-redis地址-服务端口
spring:datasource:type: com.alibaba.druid.pool.DruidDataSourcedriverClassName: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://rm-wz9qbq5wc36h2b41f.mysql.:3306/cloud?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8username: xiaohongyipassword: sz@147258xhyapplication:name: auction-centercloud:nacos:discovery:server-addr: 192.168.0.31:8848#server-addr: localhost:8848redis:database: 1host: 192.168.0.29port: 6379password: 123456timeout: 1000msjedis:pool:max-wait: -1msmax-active: 16max-idle: 8min-idle: 0redisson:address: redis://192.168.0.29:6379password: 123456server:port: 8098management:endpoints:web:exposure:include: "*"alibb:sms:accessKeyId: LTAIrXEyIBbszB9Nsecret: LiGQH9Oh3WAZ3w8kG4UwwZV5qIulA2domain: version: -05-25action: SendSmspay:# appId: 060565439456appId: 001199671097notifyUrl: /test/alipay/notify/returnUrl: /test/h5/order/returnPay/gatewayUrl: /gateway.docharset: UTF-8format: json# aliPublickey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkUxyfLvcAKZYm9s4loYBxswtnwH923bzjldZpg+m+R+guFnsncgRHAufvRApL4cQjWQQT4uhk5j+DtKGNe2B+LdXsJUtirwJHS58XBzE4IObwy1X4pYU0e3FhJx3Oq8y/RzrT2HD2TCdoKMTganIW+E6fbamU2tIqIiwP+GtaZj+EDhc9j6LBKyOXowWZjV2luQNPMbETBlLtTVssTICaEAO800Vl/8QT5SlOGpe1QtQT0qIg/LQHwLfcegLNBDN1ExoQeVgghy5M8R1vseE43B/vF9lw5MksoVXuStEuswhZpgWduxZ9tQPSGIhwQ0tMR0C+1nJ3x+Ynx0kE+W3kwIDAQAB# publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmEi0Nostyl4+uyHGP8+WbzNsZhAAx3nk6OVjoJoyAT7guVPKOAmhF2/qhM1427EvlDZ8MR83zULZ7c9clakXiBJ8+fAlOh6AN0FrC2VE4nLQaVOm1ZdCSxeVZzeVRtnvW+AekDfqslm1HTxLcZL2V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snxBYaQRq+0rktG7XHioqCWWwkkkT68cgpTdTEyJPeVDgm0XelA8X+IkxJxmqMzCrb+UsvYhwrlwfWWcXFvJNkFSzdLgHVjZWYgWgAbf9zDQ5MwgvJ7RmBurmoMEX8X6OWjLxRUsReCIpL614QKBgQDv3z2IxL3atrPRBgtGuTusTwqwCWlKsUlEow25U3WrTbzTnLjI4jbb1/Q7rEPQeqf2WZOgmxrVjj7d7CzQyB9hT74ytlYcIWpw/8HX5PBSZpfLhxhk5e2ScEYsl4rPpxNUhyKJ8nVRGT2EZJuLPJ86im3i8LhGWyFAtoNxx8sTjwKBgQDuJ4L+fWTBuEKdrMWLiAcRVAMHrS5fzzJfgjiuoV1Jyl+iJX64vni5hNYten8VbTPOz91tWigOA4rVnA/fS449HOOtfjnxtVauZ32ZxR+W0CwhTW8yTmpM1lOYf2cosKQABUFL6q9PvuQBaQTDrnLhiJtyEhRZagW1/Og+F+NAuQKBgHePlEJJnkAX9QTouFImHeJC+5bG+h5qw5RcmYiYWvxpoQbxBQHMD4AA4hGkSaDuoi2edIEHDpcHcbp379aZCVsdvjXUwJMA7Ocp89rCmC7aSCsASV5xZLsrDy9G0b+zDWWCfeq4WVV0+T62TvlV3B/3w9HsHk2jOq3gyx+5cDVtAoGAQz7C3Sr47T4jCTSEnw5suHbZWCyNQJ5XoeI6MQz9M13CPR2LN40It5GLjFHfWmR4UXgeFMd1MefMJt6nGKzT3+utWgqfP+GtNRehvm6LqeDj5Q9hS3oax9Foz1GCBlpCJINXWaFNmR3UcZV+s+YpKAeTpNT4C/tE24sq5IWINHkCgYEApteVE9JsBoOQEU2xedbgcWggGburP/kR3OZUgp0sqYofqYEvvvl/RXU854qg1+8IWWfbYg59ZFNQhCWFIk7J3xCdue0fFV26vEi48ehXmj05On2Ys4+i60wBsOSiwekdZca36XAF/lMSHLcV+xL0HNTJAybxxuvbxuUhVlvUToE=singType: RSA2# mybatis-plus相关配置mybatis-plus:# xml扫描,多个目录用逗号或者分号分隔(告诉 Mapper 所对应的 XML 文件位置)mapper-locations: classpath:mybatis/*Dao.xml# 搜索指定包别名typeAliasesPackage: com.pzhu.spring.mon.domain# 以下配置均有默认值,可以不设置global-config:db-config:#主键类型 auto:"数据库ID自增" 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";id-type: auto#字段策略 IGNORED:"忽略判断" NOT_NULL:"非 NULL 判断") NOT_EMPTY:"非空判断"field-strategy: NOT_EMPTY#数据库类型db-type: MYSQLconfiguration:# 是否开启自动驼峰命名规则映射:从数据库列名到Java属性驼峰命名的类似映射map-underscore-to-camel-case: true# 如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段call-setters-on-nulls: true# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用log-impl: org.apache.ibatis.logging.stdout.StdOutImplwx:pay:privateKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCtPHwYhTSPuuQ9enp4/vZNntCItpY0/mwEjUit1VxUP7e8o/rSQHtGmlYOrVJp5JgAHUs/Q6jpNKnW2gVP/UExov6VJsDNU7si9Rp4Ne6d821a1f+Qo3fL2hET7WS1gsGSKhchujQ3A05u+SzGsqtAsteMsK7Dj/ibnIzAypAkjO55j1tQRlv1iSC0Hlt87I0HGcKEqZbKTQBJtsaY4/rKbwHZAfM3Cg6eFo+diDq7nsTSYbnr1h/HI63Bql5KNvtrfHuI4Ye6QMN2B7UHgwfgPUT64yUczNcO+Ga2mXDLL4P3ajBws55of5FqxGpTV040QdLbcBMeaQ/BLt/2vhYfAgMBAAECggEBAKF+nFUjgJ9o47MoRZocXTJ5FgAM7rRSZhJMP2/GUj878yZJW967O/DSmd0u2IBdGRIqPOaqRYG5lYb0UjWCa09BmsEikmQXZYIuKlHcPSlEMDKZApksutXv4THJgbPwRFHlKRFJC7opO+oaIhLNpvY2gtjmMNWglmtCorhrXbqjmiHAFiSsKEkNBeLTOnevyYbBVycnsppLAzZKn5HT6aH7r2R90b1Z6B4MKLkBgFRZRB/ARtfAsKHNxYfMSKjgAKjB4/Jvp2FZ9c43pIZrySYfsukr2P8AsU1xdsEiG/iZxJNB1XnByieq5KFvdiKRqtfIeY0CJCe4/DQERxaf2+kCgYEA2fJlLuyTN/AYkA7iL8eTnjU5MxpHsEXGDdmBgyumrYspA8C2F416+EzFZujfIklg3lvGloTp3l5FtTnojWNN0nJlwqTNL071XHgV3XJoLWD8uqWZlf8K5STWtxfrASXImZmaD/N3F2OirnjHNywFxetnwlS6JwWjlZktQVssVn0CgYEAy3unQnKZTdwG1pji1JHGl/aTUp4wzP7IKlFG14KyB8DSArQQ4l/TVt0VgzWEOGn0jZbUxItVXFrOqaKJk9Ztj0LImwwHzPthoXHH4N4eJQUkXpnCpYjPXWnZh69N8aCPKnBKQFP5drV2bkfMuJcZ5byTRzbxc6ET70jo8Fm2VcsCgYAZuSE2G5f4ly7e+dK6XuzOVGvO20AwzttkURKXH7TJcM5DciBLwVgNLEp0LfIAAvca52wV4dQUeb3yeMY4wcqyluvpwDezaLdO1aGHBHTFPlg100vAR1zK1ME+1OTYutPlRRrI3SxmJ01RGFIy8dAwnusdJZDfACxhgLW1rAQcpQKBgQDGuSiMWGcoBu4WvpEokIWm+4S9dwip61mJGn9ZEabUs5dmVHz42CUJ/Dh6P9W1UqUnclqw6HKhE34pZTd/TjcJZmuMIJ+trQOYLArMraA6/16ZlQjnqUj7LdjoDmjMxcWL6MZbNKe5K1dSNITW8Zq1JwmezyXXi0RwuH/l23ebKQKBgH20WoXS3XQBUWyy52BXetMw3XYTdrv79j5GEZt3D5ThASpqA0EKU91J3iZGEObxJMUpRyzBjq2rhKTNSUm6+uAMiOIVGwJth83FExhNr0Ky97tqDEO3x2HTa170LnoyOkU8q0INHUOPLrk2mCS2u+AvaWdkuijM2AS9k7F8v7tJmchId: 1605166544mchSerialNo: 738A0DD35C04DDB9507F637F943C658C29B7E685appreqUrl: https://api.mch./v3/pay/transactions/appnotify_url: /auction-center/api/notify/weChat/notifyappappid: wxe491e99fe54ff6fapromreqUrl : https://api.mch./v3/pay/transactions/jsapiparamappid: wx01ff2c705ed0bf9drefundNotifyUrl: /auction-center/api/notify/weChat/refundNotifylogistics:key: YmAhuxLp4606customer: FC2D04B3F392335E957E6455BF98ACC6secret: 1bacd0239f6741a489580fff343af87auserid: bd46d19551a94fb299405383ca20fc09ali:pay:APP_ID: 002190661261APP_PRIVATE_KEY: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDwhzWfGwZp6w3R0UUeZczayRiPrTraBK1troKnd6ihQumyJNDj4yTi8HofbUaskML+hiAUGo/2+FIcv0bq6j0NwVD2Ac7gHn+V3fV3mi9lqOI8yR1IB+zQiZL5b3W7vCRxs3oWkG4b7YsS6LK+xACYqLpRioHXgCyP04WCgsR/DKcaL7V3zMov/zCs7Ar1D5AKUaYWhDp/RKJQ3DaBOLFTY7HDNruwJapG3Cvlzyzt4luPpTLcZqrTpraCn2t7DrGjgKcAIDaqP2GMc+NbtFTIkVoh408dTBbWEG/pmfvW/eOwFk9olSUV6fQFFPesCatI2t4BJa3uL5vNkF3sgHxNAgMBAAECggEAdOpENkJ8q5+F6CdA4bW6Dd8SAUTDBpafdmENQTn4zeoojl826o7Or0EVG5GSeO8k2XN4xEzlDbdGspKHdkjFxJnjMLFQTcCFY+OwHaLkxxWAYuufQBQaGIPG3VhAcjDRxjLndXBfFVQx9c8Gk5PSdmINrvUUiBvVjVPT4cyOlvIuSjwzXUxCBeZ0GeOivRahQu3Le+1beGOGGC+fO5hqXUVOKyI5B4YqEoJ/NPW2MPqtSV9iTCLHpcPq3UN9P5rFbd12IH922STiep3HhdU8PSHpq5431uHhUwjX6s/yId0nwYRZqMsU/WlLmv3aiGLyRfOOElPfb2CWDno/AU0MQQKBgQD5Sg3PqO1UaU7w60xwAq30/5h83gb3IAQTBs1Q17BJ8f8iRm9s/SydFGaoxWGRPUHNhd5oOY38+QuXvACHJRqzxuS7yKUdl2oY1T042r7+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hkMDTjoYyfpgtvf4rVp9eu32JayoxKtoFS0XjKgl32Rxmr2GWN9gupFFAVXT4T0IPwIIzokWU2kIhd2HBRNwvx0ZTX8B7HX7E8wKokED264CQIDAQABserverUrl: /gateway.doCertPath: /usr/local/cert/appCertPublicKey_002190661261.crtAlipayPublicCertPath: /usr/local/cert/alipayCertPublicKey_RSA2.crtRootCertPath: /usr/local/cert/alipayRootCert.crt
#!/bin/bash# 脚本中只要出现执行不是true的语句,就退出不再往下执行set -e# 导入环境变量export jar_PATH=/data/webexport APP_PATH=/home/taskexport DATA_PATH=`date +%Y%m%d`#export CONF_PATH=/home/hnpp.config/task.yml# 判断老的进程是否存在,若存在就杀掉killjar(){pid=`ps -ef|grep task |grep java |awk '{print $2}'`echo "task Id list :$pid"if [ "$pid" = "" ]thenecho "no task pid alive"elsekill -9 $pidfi}# 调用函数killjar# 判断老的jar包是否存在,若存在就删除if [ -f $APP_PATH/task-0.0.1-SNAPSHOT.jar ]; thenrm -rf $APP_PATH/task-0.0.1-SNAPSHOT.jarfi# 更新最新的jar包if [ -f $jar_PATH/task-0.0.1-SNAPSHOT.jar ]; thenmv $jar_PATH/task-0.0.1-SNAPSHOT.jar $APP_PATHfi# 重新启动#nohup java -jar -Dspring.config.location=$CONF_PATH $APP_PATH/task-0.0.1-SNAPSHOT.jar &cd $APP_PATHnohup java -jar task-0.0.1-SNAPSHOT.jar > task.$DATA_PATH.log &# sleep 10秒, 等待java进程完成起来sleep 5secho 'Start success!'[root@hnpp-1 user-center]# cat /data/sh/admin.sh #!/bin/bash# 脚本中只要出现执行不是true的语句,就退出不再往下执行set -e# 导入环境变量export jar_PATH=/data/webexport APP_PATH=/home/adminexport DATA_PATH=`date +%Y%m%d`#export CONF_PATH=/home/hnpp.config/admin.yml# 判断老的进程是否存在,若存在就杀掉killjar(){pid=`ps -ef|grep admin |grep java |awk '{print $2}'`echo "admin Id list :$pid"if [ "$pid" = "" ]thenecho "no admin pid alive"elsekill -9 $pidfi}# 调用函数killjar# 判断老的jar包是否存在,若存在就删除[ -f $APP_PATH/admin-1.0.0-SNAPSHOT.jar ] && \rm -rf $APP_PATH/admin-1.0.0-SNAPSHOT.jar# 更新最新的jar包if [ -f $jar_PATH/admin-1.0.0-SNAPSHOT.jar ]; thenmv $jar_PATH/admin-1.0.0-SNAPSHOT.jar $APP_PATHfi# 重新启动#nohup java -jar -Dspring.config.location=$CONF_PATH $APP_PATH/admin-1.0.0-SNAPSHOT.jar &cd $APP_PATHnohup java -jar admin-1.0.0-SNAPSHOT.jar > admin.$DATA_PATH.log &# sleep 10秒, 等待java进程完成起来sleep 5secho 'Start success!'
如果觉得《JAR包自动启动脚本》对你有帮助,请点赞、收藏,并留下你的观点哦!