分页: 1 / 2
求一个shell啊
发表于 : 2013-07-12 18:23
由 愤怒的阿狸
tomcat服务down掉就发送警报
Re: 求一个shell啊
发表于 : 2013-07-12 18:29
由 麦斯特
直接sleep,檢查pgrep返回值。
Re: 求一个shell啊
发表于 : 2013-07-12 19:06
由 愤怒的阿狸
检查什么来获取TOMCAT状态??
Re: 求一个shell啊
发表于 : 2013-07-12 21:15
由 zhw2101024
ps显示当前进程,然后grep过滤
Re: 求一个shell啊
发表于 : 2013-07-12 21:29
由 xjpvictor
如果是systemd的话直接 systemctl --failed,不是的话貌似用 ps aux | grep 吧
Re: 求一个shell啊
发表于 : 2013-07-13 10:36
由 愤怒的阿狸
xjpvictor 写了:如果是systemd的话直接 systemctl --failed,不是的话貌似用 ps aux | grep 吧
那发送邮件呢???
如果当掉发送邮件 ,,,,用什么程式发?
Re: 求一个shell啊
发表于 : 2013-07-13 10:59
由 noble_out
发邮件干什么,有必要么?挂掉么重启就行了!
没用过tomcat,我是用lamp,把下面的apache改成你的tomcat服务,写个定时任务到crontab中,每隔五分钟或十分中运行一下脚本就行了嘛。
代码: 全选
#!/bin/bash
web=`pgrep apache`
if [ "$web" != "" ]
then
echo "apache服务正在运行中..."
else
/etc/init.d/apache2 start
fi
Re: 求一个shell啊
发表于 : 2013-07-15 9:28
由 zhangxiaofir
这个是属于监控的 用nagios 之类的监控软件就行 脚本什么得发邮件 你得让它 1分钟运行一次?
Re: 求一个shell啊
发表于 : 2013-07-15 9:34
由 eexpress
pgrep xxxx; [ $? -ne 0 ] && yyyy;
自己cron
Re: 求一个shell啊
发表于 : 2013-07-15 12:43
由 zhw2101024
非要发邮件的话sendmail应该可以,没用过。
Re: 求一个shell啊
发表于 : 2013-07-15 12:47
由 YeLee
代码: 全选
[ -z "$(pgrep proc)" ] && echo No proc || echo Running

Re: 求一个shell啊
发表于 : 2013-07-16 11:29
由 愤怒的阿狸
zhw2101024 写了:ps显示当前进程,然后grep过滤
进程号都是随机的,这样又加大难度
Re: 求一个shell啊
发表于 : 2013-07-16 11:41
由 愤怒的阿狸
YeLee 写了:代码: 全选
[ -z "$(pgrep proc)" ] && echo No proc || echo Running

系统进程号是随机的,写脚本目的何在,就是自动化,你这样每次要查询一个进程号那还写脚本干啥。。。
Re: 求一个shell啊
发表于 : 2013-07-16 11:52
由 eexpress
愤怒的阿狸, 越来你不会man pgrep的。你没明白意思哦。
Re: 求一个shell啊
发表于 : 2013-07-16 12:19
由 麦斯特
eexpress 写了:愤怒的阿狸, 越来你不会man pgrep的。你没明白意思哦。
