通过脚本的方式杀tomcat进程(shell脚本),shell中将一个文件的内容读出赋值给一个变量

#!/bin/bash

echo "==================stop tomcat========================="
ps -aux | grep /usr/local/tomcat/ | grep -v grep > tomcat_info.txt
sed 's/  / /g' tomcat_info.txt > tomcat_info1.txt
sed 's/  / /g' tomcat_info1.txt > tomcat_info.txt
sed 's/  / /g' tomcat_info.txt > tomcat_info1.txt 
cat tomcat_info1.txt | cut -d' ' -f 2 > tomcat_info.txt

for line in `cat tomcat_info.txt`
do
    kill -9 $line
done

#/etc/init.d/tomcat stop
echo "==================stop tomcat success================="

echo "================start copy project===================="
cd /usr/local/tomcat/webapps
rm -rf xxxxxx_api*
cp -R /root/.jenkins/workspace/xxxxxx_api_pre/qt360-web/target/xxxxxx_api /usr/local/tomcat/webapps
echo "================end copy project======================"

echo "==================start tomcat========================"
BUILD_ID=DONTKILLME
#sh /usr/local/tomcat/bin/startup.sh
/etc/init.d/tomcat start
echo "==================start tomcat success================"

echo "==================start drop linux cache=============="
sync
echo 3 > /proc/sys/vm/drop_caches
echo "==================drop linux cache success============"

将一个文件中的内容读出,然后赋值给一个变量的方法:

#!/bin/bash
var=`cat file.txt`  反引号
或者
var=$(cat file.txt)

然后执行以下命令:

chmod +777 test.sh
sh test.sh
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涂作权的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值