shell 脚本监控程序是否正在执行, 如果没有执行, 则自动启动该进程
2016-07-25 06:29
1426 查看
代码里面监控1个进程, 代码很简单, 我就不讲解了, 有不懂的, 可以在回复里面问。
我看见了会给予讲解。
当然了, 该脚本要执行,你需要开启系统的定时器进程 crond , 并且编辑配置文件。
执行 crontab -e
里面输入 */1 * * * * /home/automonitor.sh 代表一分钟执行一次脚本。
[c-sharp] view plain copy
#!/bin/sh
cdnclient_pid=`ps -aux|grep -v 'grep'|grep -c '/cdn_client_D'`
ulimit -c unlimited
#echo "$cdnclient_pid"
if [ $cdnclient_pid -eq 0 ]
then
cd /home/cdnclient/
./startup.sh
cd /home/
now=`date +%Y-%m-%d[%H:%M:%S]`
echo "at $now start cdnclient -b /n" >> check_cdnclient.log
fi
http://blog.csdn.net/langeldep/article/details/6166648
我看见了会给予讲解。
当然了, 该脚本要执行,你需要开启系统的定时器进程 crond , 并且编辑配置文件。
执行 crontab -e
里面输入 */1 * * * * /home/automonitor.sh 代表一分钟执行一次脚本。
[c-sharp] view plain copy
#!/bin/sh
cdnclient_pid=`ps -aux|grep -v 'grep'|grep -c '/cdn_client_D'`
ulimit -c unlimited
#echo "$cdnclient_pid"
if [ $cdnclient_pid -eq 0 ]
then
cd /home/cdnclient/
./startup.sh
cd /home/
now=`date +%Y-%m-%d[%H:%M:%S]`
echo "at $now start cdnclient -b /n" >> check_cdnclient.log
fi
http://blog.csdn.net/langeldep/article/details/6166648
相关文章推荐
- Linux bash特性
- bash 交互与非交互
- 2、希尔排序(Shell`s Sort)
- Linux shell script学习
- shell script input and out put functuo
- shell 中的 set命令 -e -o 选项作用
- shell写俄罗斯方块二
- shell写俄罗斯方块(一)
- Shell基础学习小结
- shell脚本七十问
- bash 基本技巧
- 运行sh脚本报错:-bash: ./filename.sh: /bin/bash^M: bad interpreter: No such file or directory
- linux笔记:shell基础-概述和脚本执行方式
- 一个WIFI热点的脚本思路,顺记shell知识
- shell脚本调用另外一个shell脚本
- Spark Shell简单使用
- bash命令行快捷键
- shell中各种括号的作用()、(())、[]、[[]]、{}
- powershell新建数据库
- 常用shell命令操纵技巧