To prove what you have said when you were young! ——Alexy Young

Follow Your Heart

PM/ACP/PRINCE2……

   :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1、查看进程的一个小shell

说明:适合批量执行日志压缩,特别是日志有规律的增长的日志类型,参考如下:

ls |grep abc|grep -v gz|grep -v `date +%Y%m%d`|xargs -l -t gzip

 2、查看业务进程是否启动?如未启动则启动,如启动则提示“程序已经启动,用户名是,UID是,PID是”,可以一次自己DIY起来

#!/bin/sh
#Start the CoreProcess
cd
source .cshrc
while [1]
do
	pnums=`ps -ef|grep CoreProcess | grep -v grep | wc -l`
	http=`ps -ef|grep http | grep -v grep | wc -l`
	uid=`ps -ef|grep CoreProcess|awk '{print $2}' `
if [ $pnums -eq 0 ]
		then
				cd /opt/CoreProcess/
				./CoreProcess –d		
elif 	[$pnums -eq 1]
		then
				echo "###########################################"
				echo "###The Uid is $uid                      ###"
				echo "###########################################"
		exit;
elif [ $http -eq 0]
	then
		/usr/local/apache2/bin/httpd -k start -DSSL
elif [ $http -gt 10]
	then
				echo "###########################################"
				echo "###The Number of Processes is $http     ###"
				echo "###########################################"
	exit;		
done

 这个shll是一个最基本的模型,可以自己DIY。

有一些疑问,就是如何做并列和或的选择判断?不是很懂,得加强学习SHELL

posted on 2013-06-19 17:29  Alexy Young  阅读(185)  评论(0编辑  收藏  举报

Alexy Young CHASEDREAM