BLUESKY
一步一个脚印向前走
首页
新文章
新随笔
管理
利用shell进行批量操作
下面的shell语句是可以批量杀死进程包含rec的进程,并且利用awk输出进程号
1
for
i
in
`ps
-
ef
|
grep rec
|
grep
-
v grep
|
awk
'
{print $2}
'
`
2
do
3
echo $i
4
kill
-
9
$i
5
done
下面的语句是删除各个业务文件夹下面的文件
for
business
in
datum
do
find $SETTLE_DATA
/
filter
/
error_file
/
$business
/
-
type f
-
exec
rm {} \;
find $SETTLE_DATA
/
filter
/
index
/
$business
/
-
type f
-
exec
rm {} \;
find $SETTLE_DATA
/
filter
/
index_work
/
$business
/
-
type f
-
exec
rm {} \;
find $SETTLE_DATA
/
filter
/
repeat
/
$business
/
-
type f
-
exec
rm {} \;
find $SETTLE_DATA
/
filter
/
special
/
$business
/
-
type f
-
exec
rm {} \;
find $SETTLE_DATA
/
filter
/
rollback
/
$business
/
-
type f
-
exec
rm {} \;
done
下面的语句是判断文件夹是否为空
#
!/usr/bin/sh
output_message()
{
if
[ !
-
d $SETTLE_DATA
/
$model
/
$parent_dir
/
$business ]
then
echo
"
\t\t\t\t\t\t$SETTLE_DATA/$model/$parent_dir/$business is not a directory!
"
;
elif
[ `ls $SETTLE_DATA
/
$model
/
$parent_dir
/
$business
|
wc
-
l`
-
gt 0 ]
then
echo
"
\t\t\tThe directory $SETTLE_DATA/$model/$parent_dir/$business is not empty!
"
;
else
echo
"
The directory $SETTLE_DATA/$model/$parent_dir/$business is empty!
"
;
fi
}
for
business
in
datum
do
for
model
in
filter indb
do
#
M-EM-EM-VM-X
if
[ $model
=
filter ]
then
for
parent_dir
in
error_file index index_work repeat special rollback
do
output_message
done
#
M-HM-kM-?M-b
elif
[ $model
=
indb ]
then
for
parent_dir
in
temp notin errin work backup
do
output_message
done
fi
done
done
posted on 2007-08-02 01:10
LG
阅读(254)
评论(0)
编辑
收藏
引用
所属分类:
UnixProgram
<
2024年11月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
常用链接
我的随笔
我的评论
我参与的随笔
相册
漫画
同学
最新评论