aixshell脚本
⑴ aix下的shell脚本。 同一类文件,只保留最近时间的一份,其余删除
测试过了有点小问题,已经修改!
dir=dir_name #注意修改这里的文件夹名
cd $dir
ls XM_*_*.zip > temp1
cut -d . -f 1 temp1 >temp2 #去后缀名
sort -t _ -k 2n -k 3nr temp2 >temp3 #先按序列号再按时间排序
sort -t _ -k 2n -u temp3 >temp4
#这行是重点,-u选项是删除后续序列号重复的行在前一步已经将文件按时间排序,所以这行执行后就是需要保留的文件名
#本来这一步就差不多了,考虑到系统会定时产生文件,所以要把需要删除的文件名弄出来
grep -F -v -f temp4 temp3 >temp5 #求文件差集,temp3-temp4
cat temp5 | awk '{print $1".zip"}' | xargs rm -f #可以删除了 大功告成(测试的时候先把这行注释掉,看下几个temp文件是否是符合要求的我没测试)
rm -f temp* #最后把temp文件删除(测试的时候也要注释)
⑵ aix k shell脚本while循环调用脚本只执行单次问题
可以把数据库查询的结果输出到文件再对文件进行循环好一点
ssql="select a||'|'||b||'|'||c from table1 "
然后进入把结果输出到一个文档>>abc.unl
cat abc.unl |grep "|" |while read abc
do
a=`echo $abc|awk -F "|" '{print $1}'`
b=`echo $abc|awk -F "|" '{print $2}'`
ssh [email protected] /temp/test.ksh $a $b
done
rm abc.unl
⑶ AIX下如何去除shell脚本中的^M符号
一、去除shell脚本中的^M符号
1、用vi打开该脚本文件。
2、用替换命令删除。
:g/^M/s///g
⑷ AIX shell脚本 编写。
windows下执行shell脚步,还需要先安装cygwin环境,才能使用shell命令。
⑸ aix下如何用shell脚本根据进程的CPU占用率定时杀死进程
if test $# -gt 0 #0.0.5
then
for pname in $* #0.0.5
do
pid=`ps -e | grep $pname |sed -e '/grep/D' -e 's/^ *//' -e 's/ .*//'`
echo now killing pocess $pname pid is $pid kill -15 $pid
done
exit 0
else
echo 'usage: kpn <process_name_you_want_to_kill>'
exit 1
fi
⑹ 如何用IBM AIX命令执行SHELL脚本
AVTECH中国aix6000小机培训
⑺ aix shell脚本 对某个目录监控
#!/bin/sh
date=`date +%Y%m%d`
find /ftpdata/hjjk/ftp_down/hospital_register -name \
scoure*$date.txt \
chenggong*$date.txt \
quxiao*$date.txt \
user-$date.txt \
yytable-$date.txt \
yymsg-$date.txt \
>result 2>/dev/null
if [ $? -eq 0 ]
then
case file in
"scoure*$date.txt")
cat -n scoure*$date.txt | grep 12 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "soure*$date.txt is not nomal"
else echo "soure*$date.txt is nomal"
fi
;;
"chenggong*$date.txt")
cat -n chenggong*$date.txt | grep 17 | grep 1\^abc\^2\^abcd \
2>/dev/null && \
cat -n chenggong*$date.txt | grep 17 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "chenggong*$date.txt is not nomal"
else echo "chenggong*$date.txt is nomal"
fi
;;
"quxiao*$date.txt")
cat -n quxiao*$date.txt | grep 18 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "quxiao*$date.txt is not nomal"
else echo "quxiao*$date.txt is nomal"
fi
;;
"user-$date.txt")
cat -n user-$date.txt | grep 10 | grep 1\^abc\^2\^abcd \
2>/dev/null && \
cat -n user-$date.txt | grep 9 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "user-$date.txt is not nomal"
else echo "user-$date.txt is nomal"
fi
;;
"yytable-$date.txt")
cat -n yytable-$date.txt | grep 3 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "yytable-$date.txt is not nomal"
else echo "yytable-$date.txt is nomal"
fi
;;
"yymsg-$date.txt")
cat -n yymsg-$date.txt | grep 14 | grep 1\^abc\^2\^abcd \
2>/dev/null
if [ $? -ne 0 ]
then echo "yymsg-$date.txt is not nomal"
else echo "yymsg-$date.txt is nomal"
fi
esac
else
echo "file not find"
fi
rm -rf result
⑻ aix shell脚本中怎么把oracle查询结果保存起来
values=`select 字段A from table`
就这么简单
⑼ 在AIX小机上跑的shell脚本报错:0403-057 Syntax error at line 8 : `(' is not expected
提示很清楚了,第8行多了个单引号,其实应该是for语句上面那行,printf后面单引号使用不当。
⑽ aix shell脚本问题
mount /test1 && mount /test1/test2
或者:
if mount /test1; then
mount /test1/test2
fi