当前位置: 移动技术网 > IT编程>数据库>Mysql > shell基础入门学习

shell基础入门学习

2017年12月23日  | 移动技术网IT编程  | 我要评论

stilla kendon,民国100年,徐琰微博

1 shell的集合

declare -A ihmap=()
FILE_ALL=/opt/config/iphost
for d in `cat $FILE_ALL`;do eval $(echo $d|awk -F',' '{printf("a=%s b=%s",$2,$1)}');ihmap[$a]=$b;done

countha=0
IFS=';'
for hips in ${hadoopIp[@]}; do
let countha+=1
IFS=','
for hip in ${hips[@]};do
if [ $countha == 1 ];then
echo ${ihmap[$hip]},$hip,root,root,NN>>/opt/config/iphostuserpwdtype
elif [ $countha == 2 ];then
echo ${ihmap[$hip]},$hip,root,root,DN>>/opt/config/iphostuserpwdtype
fi
done
done

2 文件的锁定及进程的存在判断

脚本1 start.sh:

flock -xn /var/run/aa.lock -c 'sh /opt/scripts/start_all.sh $1'

脚本2 start_all.sh:

真正执行任务的脚本,略

进程判断

可尝试:

infos=$(ps -ef|grep '' |grep -v grep);

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网