Shell脚本检测Tomcat是否正在运行
#!/bin/sh
# configurations
# computer 设备名称
# target 监控目标
# watcher 跟踪者(邮箱) computer="ehetong"
target="home/ehetong/apache-tomcat-7.0.33"
date_time=$(date +%c) # 收件人
email_addressee="952589031@qq.com 823633682@qq.com"
# 发件人
email_sender="do-not-reply@itrusign.cn"
# 发件人用户名
email_user="do-not-reply@itrusign.cn"
# 发件人密码
email_password="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# smtp服务器地址
email_smtp="smtp.exmail.qq.com" # 邮件标题
email_title=${computer}"机器TOMCAT进程意外关闭-"${date_time}
# 邮件内容
email_content=${computer}"---"${target}"\n在"${date_time}",Tomcat进程意外关闭\\nshell脚本搜索不到Tomcat进程PID,请及时处理。" #tomcat=$(ps -ef|grep $$target | grep -v grep | awk '{print $2}')
tomcat=`ps -ef|grep $target | grep -v 'grep\|tail' | awk '{print $2}'` #file_path=""
# 附件
# file_path=""
# -a ${file_path} if test -z ${tomcat}
then
echo $(date +%F" "%T)"--info--:准备发送邮件"
/usr/local/bin/sendEmail -f ${email_sender} -t ${email_addressee} -s ${email_smtp} -u ${email_title} -xu ${email_user} -xp ${email_password} -m ${email_content} -o message-charset=utf-8
echo $(date +%F" "%T)"--info--:发送邮件成功"
else
echo $(date +%F" "%T)"--info--:tomcat进程存在,pid="${tomcat}
fi
Shell脚本检测Tomcat是否正在运行的更多相关文章
- windows下脚本检测tomcat是否启动,没有启动则启动
最近有个服务需要部署到windows server2003上面,机房没有windows ser的机器,没办法搞了个阿里云服务,购买的配置比较低, 不知道什么原因,tomcat启动后总是容易自动退出,搞 ...
- 多线程shell脚本检测主机存活
局域网中分了很多网段,而IP地址使用情况也未知,前期也没有规划和记录,当新的主机需要使用固定IP的时候,能否第一时间知道哪个IP空闲就显得很重要了,如果一个一个去ping的话太浪费时间. 这里分享一个 ...
- shell脚本关闭tomcat
使用shell脚本快速关闭tomcat,就是获取tomcat进程后,一起kill掉: #!/bin/sh #kill tomcat pid name=tomcat-emall pidlist=`ps ...
- shell脚本重启tomcat
1. 新建shell空脚本文件,如 /home/tr.sh,并设置权限 # chmod 750 /home/tr.sh 2. 设置文件形式: # sed -e 's/\^M//g' /home/tr. ...
- 关于windows下编写的shell脚本在linux下无法运行报错问题
首先,你写的shell脚本必须是正确的, 其次,无法运行的原因:因为windows下的换行是两个字节,而你上传到linux,linux下换行是两个字节,所以编译的酒不正确的,导致无法 运行脚本, 这种 ...
- liunx 使用crontab定时任务+shell脚本删除tomcat日志elasticsearch日志索引
由于过多的日志很占用磁盘空间,今天经理让我写一个脚本删除多余的日志.和es索引 定时删除试根据crontab+shell脚本实现的 crontab配置目录 /var/spool/cron/ 该目录下存 ...
- (原创)Windows下编译的Shell脚本不能再Linux中运行的解决办法
一.原理 Windows编译的文件和Linux编译的文件格式不太一样,导致在Linux运行Shell脚本的时候会提示:/bin/bash^M: bad interpreter: 没有那个文件或目录. ...
- linux shell脚本检测硬盘磁盘空间 邮件报警
使用 http://www.weiruoyu.cn/?p=368 shell脚本监控硬盘空间剩余空间 邮件报警 1.先观察一下磁盘,和如何使用脚本 [root@localhost ~]# df -h ...
- WyBox使用shell脚本检测io口是否正常
1. 修改mt7620a.dts文件,把gpio管脚复用全都定义为通用gpio /dts-v1/; /include/ "mt7620a.dtsi" / { compatible ...
随机推荐
- CSS3媒体查询能检测到的特性小结
CSS3的Media Queries能够检测到的特性总结: 视口(viewport)解释地址:http://baike.baidu.com/view/1522985.htm width:视口宽度的检测 ...
- JMeter学习-039-JMeter 3.0 生成 dashboard HTML 报告图表中文乱码
近期,经常有人问 JMeter 3.0 使用时,生成的 HTML 报告图表中的中文乱码问题.在此,简略的说一下解决的方法. 编码相关信息如下: 1.查看控制 csv.xml 等配置结果文件生成.读取的 ...
- LeetCode Reverse Vowels of a String
原题链接在这里:https://leetcode.com/problems/reverse-vowels-of-a-string/ 题目: Write a function that takes a ...
- linq 左连接
var list = (from item in vall join item3 in v1 on new { item.FItemID, item.FAuxPropID } equals new { ...
- EXC_ARM_DA_ALIGN
ios 版本上的问题 armv7 ipad2 int64 t = *(int64*)pBuff; 如果pBuff不是8字节对齐的地址就 crash 变通的方法是通过memcpy __sync_fe ...
- Configure LDAP Server(centos7 openldap)
1.安装openldap -server: [root@dlp ~]# yum -y install openldap-servers openldap-clients [root@dlp ~]# c ...
- PostgreSQL 磁盘使用大小监控
表大小信息 postgres=# SELECT *, pg_size_pretty(total_bytes) AS totalpostgres-# , pg_size_pretty(index_byt ...
- Visual Studio 2015 Update 3 正式版下载
vs2015-update3 .NET Core 1.0 文件名 cn_visual_studio_enterprise_2015_with_update_3_x86_x64_dvd_8923 ...
- [osx] 查看端口被占用
netstat命令 netstat -an | grep 3306 3306替换成需要grep的端口号 lsof命令 sudo lsof -i :80 -i参数表示网络链接,:80指明端口号,该命令会 ...
- web应用安全防御100技 好书再次阅读, 变的只是表象,被概念迷惑的时候还是静下心来回顾本质
如何进行web应用安全防御,是每个web安全从业者都会被问到的问题,非常不好回答,容易过于肤浅或流于理论,要阐明清楚,答案就是一本书的长度.而本文要介绍一本能很好回答这个问题的优秀书籍——<we ...