标签:格式化 xargs tms 脚本 try lan tom $# .sh
#!/bin/bash # 定义环境变量 export LANG="en_US.UTF-8" #统一格式化打印输出信息 printMsg(){ echo "$(date +‘%Y-%m-%d %H:%M:%S‘)-----------$1-----------" } #输入参数个数检查 if [ $# -lt 3 ]; then printMsg "脚本参数错误,例如:./startup.sh projectA 8080 docker.registry.cn:5000/projectA:v1" exit 1 fi curTimeStr="$(date +‘%Y%m%d%H%M%S‘)" proName=$1 port=$2 imageUrl=$3 #stop old docker ps |grep ${proName} | awk ‘{print $1}‘ | xargs docker stop docker run -it -d -p ${port}:8080 --name ${proName}-${curTimeStr} -v /tomcat7/logs:/tomcat7/logs ${imageUrl}
标签:格式化 xargs tms 脚本 try lan tom $# .sh
原文地址:http://www.cnblogs.com/qiang-cnblog/p/7762652.html