周末写了个 monitor filesystem shell ( crontab 定时监控)
来源:互联网 发布:淘宝达人个人简介模版 编辑:程序博客网 时间:2024/06/06 18:41
现在公司的 oracle 文件的 归档filesystem 下太大了,而且要是录用达到100% oracle 的用户是connect 不上去的,于是决定 写个监控的shell:
思想: 归档的日志有大有小,当filesystem 在20% 一下就可以认为正常,不要删除,否则就要delete old files.
1:好下面来看以下shell: (是放在/tmp/test/monitor.sh)
#! /bin/ksh
# Function: This shell is to monitor the filesystem.
# Date: Dev 05 2010 sunny Sunday
# step1 To to check the filesytem, if it more than 20%,then delete the old files, otherwise to do nothing.
df -g > checkfile
grep '/dev/arch' checkfile > ch01
awk '{$print $4}' ch01 > ch02
ch03=ch02
ch04 = `cat $ch03`
if [ "$ch04" -ge 20 ]; then
continue
else
echo "The file system is okay now ,please contunie to work! ^_^ "
fi
#step2 : if the filesystem usage more than 20%, delete the old files, keep the latest 10 files.
Dir=/root/temp/data
cd $Dir
ls -lt | awk '{if(NR>11) {print "rm " $9}}' | sh
# step3 check the status:
if [ $? == 0 ]; then
echo " The filesystem is okay now, please continue to work !"
else
echo " Please double check the filesytem! "
fi
-----------------------
2:利用crontab 来定义shell 的运行规律:
写个frequently shell: fre.sh 放在/tmp/test
(每两小时执行一次)
#cat fre.sh
0 */2 * * * /tmp/test/monitor.sh
3: 在aix 系统中定制这个fre.sh
#crontab /tmp/test/fre.sh
看了上面的shell ,大家有啥感想呢? shell 是为了更好的工作,为工作所用。呵呵,下面我有个想法,就是把这个监控报告定时发送到我的outlook 邮箱。make monitor easy!
- 周末写了个 monitor filesystem shell ( crontab 定时监控)
- 写了个监控的shell ,望指点
- 写了个监控网络流量的脚本
- crontab 定时执行shell脚本
- crontab 定时执行shell脚本
- shell-crontab(定时调度)
- crontab 定时执行shell脚本
- 用shell写个简单的log监控程序
- 天热,周末宅家,写了个BUG满天飞的Debug调试器
- Unix 定时执行Shell方法.. crontab
- crontab+shell实现java文件定时运行
- linux 定时执行shell脚本 crontab
- Shell脚本之crontab定时任务
- Crontab 让linux定时执行shell脚本
- 使用crontab定时执行shell脚本
- linux shell 定时任务 之 crontab
- Shell脚本之crontab定时任务
- Shell脚本之crontab定时任务
- linux内核编绎流程详解
- Android Looper和Handler分析
- 使用双缓冲让界面绘制图形时避免闪烁 整理
- qss
- 动态加载用户控件函数
- 周末写了个 monitor filesystem shell ( crontab 定时监控)
- 如何理解接口和抽象类 或何时用接口何时用抽象类
- 原来《精通Dojo》里用的dojo版本不超过1.1.2,而现在都1.5了……
- hadoop 配置
- javascript 注意
- SQL Server删除所有表的小脚本
- Linux/Unix环境下的make和makefile详解(非常详细)
- C语言程序设计综合作业报告——作业管理系统
- Copy txt file